Java EE694c
Java EE694c
1. Add two numbers by taking input using Command Line Input, Scanner class and
BufferedReader class.
2. Create a class; make its instance variable and method. Use them from main, declared
in different class.
3. Create a class First, make instance variable [int x], method [void show()] and also put
main method inside that class and use the instance variable and method from main.
4. Write a program to find surface area and volume of Cylinder Using Constructors -
Keyboard Input or Command Line Input.
5. Write a program to find surface area and volume of Cone Using Constructors -
keyboard input or command line input.
6. write a program to add two complex numbers using concept of method returning
object and method taking object as parameter.
7. Write a Java code to find a number from an array of numbers.
8. Write a Java code to take ten numbers as input and sort them is ascending order.
9. Write a Java code to search an element using binary search.
10. Show that static block execute before any object creation and implement the use of
static variable.
11. Create a class; put a method inside this class which will return a class reference return
same class and/or different class object.
12. See the problems below:
a) Write a JAVA Program to make a Student class with proper attributes like roll
no, name, stream, and college. From main create such two students and show their
information.
b) Write a JAVA Program to consider the Student class in the previous Program.
Assume that a student studies 6 subjects. Each subject has a title, internal marks and
theory marks. Write a Program to define Student class including the subjects as array.
From main create such two students and show their information including subjects’
name and grand total marks.
c) Write a JAVA Program to consider the Student class in the first Program 8a.
Assume that students study varying number of subjects. Each subject has a title,
internal marks and theory marks. Write a Program to define Student class including
Academy Of Technology
the subjects as vararg argument of constructor. From main create such two students
and show their information including subjects’ name and grand total marks.
13. Design a class to represent a Bank Account. Include the following things:
Fields
Name of the depositor
Address of the depositor
Account number
Balance amount in the account
Methods
To assign initial values
To deposit an amount
To withdraw an amount after checking balance
To display the name, address and balance of a customer
From main create object and call these methods.
1. Create a class and determine if method overloading holds good for return type of
methods or not.
2. Create an abstract class Shape with two abstract methods, area() & disp(). Now
design three concrete classes Rectangle, Circle & Triangle can compute area and
display its separately.
3. Overload the constructors for classes Area and Volume of a rectangular figure and
also display its area and volume. Area is the superclass and Volume is the subclass.
4. [*] Create a class Employee is having instance variables name and id. Create its
subclass named Scientist which has instance variables no_of_publication and
experience. Now create its subclass, say DScientist which has instance variable
award. Put a method like: public String toString(){ } in every class where
you describe about the class and from main() method create object of each class and
print each object.
5. Create a class with a method void show() and make three subclasses of it and all
subclasses have this show() method overridden and call those methods using their
corresponding object references.
Academy Of Technology
9. Create a class Parent having instance variables id,name and address. Create a
class ChildOne having instance variables id,name,address and marks. Also
create another class ChildTwo with instance variables id, name, address,
qualification and salary.Within each class define your own method to display
values of these variables. Design the program using super call with proper
parameter and use object of each class from main() to display their properties.
2. Create a class which contains an inner class. Show that inner class can use member
of outer class directly, but Outer class can use member of Inner class only through its
object. Check the name of class file, you created.
3. Create two interfaces, each with two methods. Inherit a new interface from the two,
adding a new method. Create a class by implementing the new interface and also
inheriting from a concrete class. In main() method, create an object of derived class
and call the methods [do all without package statement].
4. Write a program to demonstrate anonymous inner class (using super class and
interface).
5. Show that ordinary block is executed when object is created and also the order of
execution of these blocks (for multiple blocks/ inherited block).
6. Show that static block is executed at the time of class loading and also the order of
execution of these blocks (for multiple blocks/ inherited block).
7. Write a program to show the difference between ordinary block and static block.
8. Write a program to demonstrate the order of execution among the parent and child’s
static and non-static blocks.
9. Create a class with variable(s) and method(s) (all will be default accessed) under
package pOne. Now create a class under package pTwo, which is subclass of firstly
created class. In the method here (i.e. class of pTwo) call variable(s) and method(s) of
previous class (i.e. class of pOne). If errors come, rectify them. Now from Main
(under working directory) access second class’s members.
10. Create an interface containing three methods, in a package ‘pkgOne’. Implement the
interface from a class under package pkgTwo. From main, under working directory,
create object of the class and call methods of interface.
1. Take a sting from keyboard and convert into character array (new one).
2. Take a string from keyboard and a char array (filled up to length 5). Now append the
string to that char array. Show the char array.
3. Write a java code to differentiate equals() method and == operator.
4. Find length of a string taken from keyboard and also find the length of that string
except front and end spaces.
5. Write a Java code to sort ten names in ascending order.
6. Check if "Tech" presents in "University of Technology" or not. If yes return its
position.
Academy Of Technology
7. Write a program to take a sentence and convert it into string arrays and sort the words
using any sorting technique.
8. Show that the String class type objects are immutable but StringBuffer class objects
are mutable.
9. Convert the StringBuffer type object into a String object. Print the final result.
10. Write a program in Java that checks whether a given string is a palindrome or not.
Ignore the cases.
11. Write a program in Java that converts a string into an array of strings and display
them [use command-line argument].
12. Write a program in Java that accepts a shopping list of five items from the command
line and stores them in a vector.
13. Write a program to concatenate the contents of two Strings .
9. Write a demo program to illustrate the restrictions of using ‘throws’ clause in method
overriding with regard to superclass-subclass concept.
1. Inherit a class from Thread and override the run( ) method. Inside run( ), print name
of thread , and then call sleep( ). Repeat this three times, then return from run( ). Put a
start-up message in the constructor. Make your thread object and main thread run to
see what happens.
2. Implement a class from Runnable and override the run( ) method. Inside run( ), print
full qualified name of thread, and then call sleep( ). Repeat this three times, then
return from run( ). Put a start-up message in the constructor. Make your thread object
and main thread run to see what happens.
3. Make several threads (say 5) with names (by extending thread), set their priority and
run them to see what happens.
4. Make several threads (say 5) with their names (implementing Runnable) set their
priority and run them to see what happens.
5. Write a program to use join() and isAlive() in Multi-Threading.
6. Implement program of locking of common method by several threads. (Using the
keyword ‘synchronized’).
7. Write a program to implement inter-thread communication: the consumer consumes
items produced by the producer with proper synchronization.
8. Write an Applet code to calculate speed of a car. Take input distance and the time
using Text field.
9. Write an Applet code to implement concept of ComboBox (Choice).
10. Write a JAVA Program to create a Frame with Six Buttons representing your favorite
six colors. When button is clicked, the background must be change to the
corresponding colors.
11. Write a JAVA Program to create a window with four text fields for the Name, City and
Pincode with suitable labels. Also the window contains a button MyDetails . When the
user types the Name, his Street, City and Pincode and then clicks the button, the typed
details must appear in Arial Font, size 30, Italics.
12. Write a JAVA Program to create a Frame with three text fields for Name, Age and
Qualification and a text field of multiple lines for address.
13. Write a JAVA Program to create a window with a TextArea and two TextFields. The
TextFields are called Find and Replace respectively. There is a button called Find and
Replace. The user types a paragraph in the Text area, now types a word in the Text field
Find and another text in the text field Replace. Now the users click the button. On
pressing the button the paragraph in the text area is subject to the Find and Replace
activity.