Java Program
Java Program
Unit-1
(5)Write a program to calculate the area of square and rectangle by overloading the area method.
(6)Write a java program to display powers of 2 i.e. 2,4,8,16 etc up to 1024 using bitwise operators.
(9)Create a complex number class. The class should have a constructor and methods to add,subtract and
multiply two complex numbers and to return the real and imaginary parts.
Unit-2
(1)Write a program to print even number up to 10 using while loop.
(4)Write a program to create an array to store 5 integer values. Also initialize the array with 5 numbers and
display the array Elements in reverse order.
(5)Write a program to create integer array containing 10 values. Then print all the prime numbers contained
by the array.
(8)Write a java program that accepts a string from users and display each character on separate line in reverse
order.
(10)Write a program to create a string using the string class and check whether the string is a palindrome or
not. A string is a palindrome that is spelled the same both forwards and backwards.
Unit-3
(1)Write a program to display the sum of digits of given numbers with exception handling.
(2)Write a java program which takes 2 arguments a string and its length. If the length of the string is not
according to given one then throw the user defined LengthMatchException and handles it appropriately.
(5)Write a program to define custom exception called"no match exception" that is thrown when a string is not
equal to "internet" This string is providing through commandline argument.
(7)Consider an employee class, which contains fieldssuch as name and designation. And a subclass, which
contains a field salary. Write a program for inheriting this relation.
(9)Write a program to calculate arithmetic mean in the superclass and standard deviation in the subclass.
Unit-4
(1)Write a program to calculate the area by using an interface.
(4)Write a java program to create 3 threads using Thread class. Three threads should calculate the sum of
1 to 5, 6to 10 and 11 to 15 respectively. After all thread finishes main thread should print the sum and
average.
(5)Write a java program that accepts marks of 5 subjects from display the average. If any value is not between
0 and 100 then throw custom exception Range Exception and handle it.
(8)Write an applet that take three numbers as parameters and displays their sum and average.