Professional Documents
Culture Documents
Possible Questions
Possible Questions
PART B
UNIT 1
1. Define a class named COMPLEX for representing complex numbers that contains necessary data me
mbers and member functions. A complex number has the general form a + ib, where a is the real part and
b is the imaginary part (i stands for imaginary). Include methods for all the four basic arithmetic operators
1. ‘transact’: with class ‘Transaction’ with static methods credit() and debit()
2. ‘loan’: with class ‘LoanAccount’ with method doTransaction() which calls Transaction class
methods
Create one ‘LoanAccount’ object in main to perform operations on it by accepting command line
arguments
3. i) Write a java program to find whether the number is odd or even numbers in an array.
ii) Write a java program to check whether the given string is a palindrome.
UNIT 2
1. Define an interface “QueueOperations” which declares methods for a static queue. Define a class
“MyQueue” which contains an array and front and rear as data members and implements the above
interface. Initialize the queue using a constructor. Write the code to perform operations on a queue object.
Take an integer array of size 20, initialize values randomly between 10 and 90, simultaneously
sum all values and calculate average. Now separate values below average and above average in
ArrayLists. Finally print both lists in 2 separate rows.
3. Write a Java program for run time polymorphism ?
UNIT 3
1. Write a java program for exception handling:
a. To create a user defined exception whenever user input the word “hello”.
b. To add two integers and raise exception when any other character except number (0 – 9) is
given as input.
2. Create a class Doctor with attributes id, name, age and department. Initialize values through
parameterized constructor. If age of Doctor is not in between 25 and 65 then generate user-defined
exception “AgeNotWithinRangeException”. If name contains numbers or special symbols raise exception
“NameNotValidException”. Define the two exception classes
UNIT 5
1, Create a new Java GUI application to convert miles to kilometers when pressing the
“Convert!” button. Note that you need to implement the ActionListener interface and override
the actionPerformed() method. Note that 1 mile is equal to 1.609 kilometers.
2. Create a new Java GUI application that moves a snowman on a panel. The position of the
snowman can be changed using the control buttons. With the four buttons, a user can move the
snowman to the left, right, up or down position.
3. Write a Java program to toggle the background color on every click of button.