Practical Question Bank (Java-I)
Practical Question Bank (Java-I)
Set-1
1) Write a Program to print all Prime numbers in an array of ‘n’
elements.
(use command line arguments)
2) Define an abstract class Staff with protected members id and
name. Define a parameterized constructor. Define one subclass
OfficeStaff with member department. Create n objects of OfficeStaff
and display all details.
Set-2
1) Write a program to print an array after changing the rows and
columns of a given two-dimensional array.
2) Write a program to design a screen using Awt that will take a user
name and password. If the user name and password are not same,
raise an Exception with appropriate message. User can have 3 login
chances only. Use clear button to clear the TextFields.
Set-3
1) Write a program for multilevel inheritance such that Country is
inherited from Continent. State is inherited from Country. Display the
place, State, Country and Continent.
2) Write a menu driven program to perform the following operations
on multidimensional array
i.e matrices :
a) Addition
b) Multiplication
c) Exit
Set-4
1) Create a class Sphere, to calculate the volume and surface area of
sphere.
(Hint : Surface area=4*3.14(r*r), Volume=(4/3)3.14(r*r*r))
2) Design a screen to handle the Mouse Events such as
MOUSE_MOVED
and MOUSE_CLICKED and display the position of the Mouse_Click in a
TextField.
Set-5
1) Define an interface “Operation” which has method volume( ).Define
a constant PI having a value 3.142 Create a class cylinder which
implements this interface (members – radius, height). Create one
object and calculate the volume.
10)Write a program to accept the username and password from user if
username and password are not same then raise "Invalid Password"
with appropriate msg.
Set-6
1) Write a program to find the Square of given number using
function interface.
2) Write a program to design a screen using Awt that,
Set-7
1) Write a program to accept the two dimensional array from user and
display sum of its diagonal elements.
2) Write a program which shows the combo box which include list of
T.Y.B.Sc.(Comp. Sci)
Subjects. Display the selected subject in a text field.
Set-8
1) Write a Program to illustrate multilevel Inheritance such that
country is inherited from continent. State is inherited from country.
Display the place, state, country and continent.
2) Write a package for Operation, which has two classes, Addition and
Maximum. Addition has two methods add () and subtract (), which are
used to add two integers and subtract two, float values respectively.
Maximum has a method max () to display the maximum of two
integers
Set-9
1) Create a class Student(rollno, name ,class, per), to read student
information from the console and display them (Using
BufferedReader class)
2) Create the following GUI screen using appropriate layout manager.
Accept the name, class, hobbies from the user and display the
selected options in a textbox.
Set-10
1) Define a Item class (item_number, item_name, item_price). Define
a default and parameterized constructor. Keep a count of objects
created. Create objects using parameterized constructor and display
the object count after each object is created.(Use static member and
method). Also display the contents of each object.
2) Define a class ‘Donor’ to store the below mentioned details of a
blood donor. name, age, address, contactnumber, bloodgroup, date of
last donation. Create ‘n’ objects of this class for all the regular donors
at Pune. Write these objects to a file. Read these objects from the
file
and display only those donors’ details whose blood group is ‘A+ve’ and
had not donated for the recent six months.
Set-11
1) Write a program that reads on file name from the user, then
displays information about whether the file exists, whether the file is
readable, whether the file is writable, the type of file and the length of the
file in bytes.
Set-12
Set-14