Core Java Assignments

1. Create two String objects and assign with different strings. For eg.
String str1=”Hello”;
String str2=”mayi”;

Write a program to create a new String object, as odd characters for str1, and even characters from str2
Considering above example: output: Hmealylio

2.Take six different one digit integers. output the largest integer that can be created, by combining these six integers. NOTE: six digits can be same or different

3.Two dimensional arrays(with same number of rows and columns), each element stores an object of below class

class Abc{
int i;
}

Write a program to change rows to columns, and columns to rows.

4.serialize employee objects, and write a client which serializes employee objects to OutputStream, of a socket. Receive the object stream, at the server, and write to a file.

5. Take some String as below
String str=”Hello, how are you? Can you come here?”;

create two child threads, from main thread. Each child thread prints one character at a time. But the thread need to be locked until it completes printing the word. Hint: you can use synchronized method or block.

6. For a given integer value, for eg. 4823, print it in words, like four thousands, eight hundreds and twenty three.

7. Find transpose a matrix of given number of rows and cols?

8. multiply two matrices, and generate third matrix?

9. print factorial of a given number, using recursion?

10. Ask user to enter a name, if name is numeric, then throw NotaNameException. Create your own Exception called NotaNameException

11. Declare and initialize an array of size 5, each element can be any number between 0 and 9. Print each element in string equivalent with comma separated.
For eg. int arr[]={4,2,5,1,6}; need to print four,two,five,one,six

12. Billing amount is entered by shop keeper. If the bill amount is less than 5000, give 5% discount.
If bill amount between 5001 and 10000, give 8% discount.
If bill amount between 10000 and 20000, give 10% discount.
If bill amount between 20001 and 50000, give 15% discount.
If bill amount is greater than 50001, give 18% discount.

In all cases compute, the result bill amount, after giving discount.

13. Declare an array of Object elements. Store objects of different types in the array. Fetch each element(which is an object) from array, and print object’s class name, methods available, etc… by using Reflection.

14. A String is provided in the format 19,8,23 . Write a program to extract integers, check if these numbers occur in sequential order.

15. Declare an array of odd length. In this array swap only elements with even index.

16. Write a program to print a String “abcdef”
(1) fedcba
(2) a
ab
abc
abcd
abcde
abcdef
(3)a
b
c
d
e
f

(4) a
b
c
d
e
f
(5)a f

b e

cd

17.Write a program to convert a decimal number to binary form, and print.

18.Write a program to convert a decimal number to octal form, and print.

19.Write a program to print multiples of 3 or 5 between 1000 and 1050.

20.Write a program to print multiples of 23 between 2000 and 1000, in reverse order.

21.Write a program to print all numbers having same digits between 10 and 999. For eg. 22 or 555,etc…

22.Display all prime numbers between 1 and 100. Note: A Prime number is a number whcih is divisible only by 1 or by itself. Eg. 3 is prime number.

23.Write a program to print all numbers, which has sequence digits, for eg. 234, 678, 1234, which are between 10 and 1000.

You may also like to read:
More Core Java assignments
Core Java assignments

Frequently asked Project interview Questions