0% found this document useful (0 votes)
23 views5 pages

LAB MANUAL OOPS USING JAVA

practice oops questions

Uploaded by

FLAME OF PEACE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views5 pages

LAB MANUAL OOPS USING JAVA

practice oops questions

Uploaded by

FLAME OF PEACE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

LUCKNOW PUBLIC COLLEGE OF PROFESSIONAL STUDIES

BCA SEM III

LAB MANUAL

Paper Code: NBCA-306P Paper Name: OBJECT ORIENTED PROGRAMMING & JAVA LAB

Q1) Body Mass Index (BMI) is a measure of health on weight. It can be calculated by taking your weight
in kilograms and dividing by the square of your height in meters. Write a program that prompts the user
to enter a weight in pounds and height in inches and displays the BMI.
Note:- 1 pound=.45359237 Kg and 1 inch=.0254 meters.

Q2) Write a java program to generate the electricity bill based on the following criteria

Reading(unit) Rate

For First 100 units - Rs 1.75/unit

For next 100 units -Rs 3.50/unit

Above 200 units - Rs 5.20 /unit

Q3) Write a program to print out all the Armstrong numbers between 1 & 500.

Q4) Write java class that contains appropriate methods to find the greatest number, LCM for two given
numbers.

Q5) Write a java program to generate all the combinations of 1,2 & 3 to form different numbers using
for loop.

Q6) Write a shell script to accept temperature of city in Fahrenheit & convert the temperature into
centigrade degrees.

Q7) Write a menu driven program which has the following options:-

i) Prime or not
ii) Odd or even
iii) Armstrong or not

Q8) Write a java program to input a number & convert the inputted the number in words

Input: 7893

Output: Seven Eight Nine Three


Q9) Write a java program to input a number & convert the inputted the number in words

Input: 78935

Output: Seventy Eight Thousand Nine Hundred Thirty Five Only

Q10) Write a java program that asks the user to enter an amount and prints number of
notes (of denominations 500, 100, 50, 20, 10, 1) to be distributed. For example, if the user
enters $451, then 4 note of 100, 1 note of 50 and 1 note of 1 is required.

Q11) Write a program to create a class Student with data ‘name, city and age’ along with
method printData to display the data. Create the two objects s1 ,s2 to declare and access
the values.

Q12) Write a program in java to enter the number through command line argument if first
and second number is not entered it will generate the exception. Also divide the first
number with second number and generate the arithmetic exception.

Q13) Write a program in java to enter the number through command line argument if first
and second number .using the method divides the first number with second and generate
the exception.

Q14) Write a java program in which thread sleep for 5 sec and change the name of thread.

Q15) Write a java program for multithread in which user thread and thread started from
main method invoked at a time each thread sleep for 1 sec.

Q16) Write a java program for to solve producer consumer problem in which a producer
produce a value and consumer consume the value before producer generate the next
value.

Q17) Write a java program that checks whether a given string is palindrome or not.

Q18) Write a java program to create a class named Fun & use method overloading to
display the number of arguments & values of those arguments.

Q19) Write a java program to create a class named room containing length & breadth that
signifies room dimension inherit the above class into a bedroom class & display the
rvolume with appropriate methods.

Q20) Write a java program that implements method overriding?


Q21) Write a java program that create a class named figure containing data members dim1,
dim2 use appropriate constructors to initialize the data values. Declare a method named
area that displays the message that area of figure not defined. Inherit the above class to
Rectangle class use necessary constructor that call the base class constructors & then
override the area method of base class to calculate the area of Rectangle. Now derive a
new class triangle from figure class & override the area methods of base class to calculate
the area of triangle?

Q22) Write a java program to demonstrate the access of public & private data members of
check class via a accesscheck class?

Q23) Write a java program to demonstrate the pass the parameters by reference to a
method of check class?

Q24) Write a java program to create an abstract class named one that contains an abstract
method name callit() & a method named as callitalso(). Create a new class named two
that is derived from the above mentioned class & implements the abstract method of the
base class. Now create object of the derived class to call the above methods?

Q25) Write a java program to create an abstract class named shape containing the data
members dim1, dim2 use appropriate constructor for initialization purpose. Declare a
method area of abstract nature. Derive a new class named Rectangle from the above base
class use constructor of derived class to call the constructor of base class & also override
the abstract method of base class to return the area of the rectangle. Also derive a class
named triangle to implement the method area to calculate the triangle area. Create object
of the above derived class to display the resultant area of each of them.

Q26) Write a java program to input two double dimension matrix & display the result after
matrix multiplication?

Q27) Write a java program to create two array that contains the elements in ascending
order. Now merge the above array & maintain the order of the list of elements in the
merged array?

Q28) Write a java program to input a string & replace existence of “is” with “was” in the
modified string?

Q29) Write a java program to insert an element into array at specific position?

Q30) Write a program to print the revering of the list of string?


Q31) Write a program to arrange the group of string in alphabetical order?

Q32) Write a program to create an interface named area containing data members pi &
compute method define a rectangle class that implements the interface & return the area.
Now define a class named circle that implements area interface to calculate the area of the
circle?

Q33) Write a java program to create a interface named newshape containing draw()
method. Extend the above interface into circle interface containing getradius() method &
data member radius. Create a NewCircle class that implements the extended interface.
Create a class extend interface that inherit the above class & call the

Q34) Write a program to demonstrate the priority of threads using run() method?

Q35) Write a program to demonstrate the use of runnable interface?

Q36) Consider trunk calls of a telephone exchange. A trunk call can be ordinary, urgent or
lightning call. The charges depend on the duration and the type of the call. Writ a program-
using concept of polymorphism in Java to calculate the chases.

Q37) Write a program to make a package Balance in which has Account class with
Display_Balance method in it. Import Balance package in another program to access
Display_Balance method of Account class.

Q38) Write a program in Java to create a Player class. Intermit classes Cricket _Player, Football _Player
and Hockey_ Player from Player class.

Q39) Write a class Worker and derive classes DailyWorker and SalariedWorker from it. Every worker is
has a name and a salary rate. Write method ComPay( int hours) to computethe week pay of every
worker.A DailyWorker is paid on the basis of number of days s/he work.The SalariedWorker g ets paid
the wage for 40 hours a week no matter what actual hours is. Test this program to calculate the pay of
workers. You are expected to use concept of polymorphism to write this program.

Q40) Write a program in java which implement interface Student which has two methods Display_Grade
and Atrendance for PG_Students and UG_Students( PG_Students and UG_Students are two different
classes for Post Graduate and Under Graduate students respectively).

Q41) Write a program in Java to display name and roll number of students. Initialize respective array
variables for 10 students. Handle ArrayIndexOutOfBoundsExeption, so that any such problem doesn‟t
cause illegal termination of program.

Q42) Write a java program to facilitate user to handle any chance of divide by zero exception
Q43) On singles track two vehicles are running for as vehicles are going in same direction there is no
problem. If the vehicles are running in same direction there is a chance of collision. To avoid collisions
write a java program using exception handling. You are free to make necessary assumptions.

Q44) Write a java program to create five threads with different priorities. Send two threads of highest
priority in sleep state. Check the aliveness of the threads and mark which dread is long listing.

Q45) Writ a program in java to create a String object. Initialize this object with your name. Find the
length of your name using appropriate String method. Find whether character „a‟ is in your name or
not, if yes find the number of time „a‟ it appear in your name. Print locations of occurrences of „a‟ .Try
same for different String objects.

Q46) Write program in Java for String handling which perform followings

i) Checks the capacity of StringBuffer objects


ii) Reverse the contents of a string given on console and convert the resultant string in upper case.

iii) Read a string from console and append it to the resultant string of ii.

Q47) Write Java program to show that private member of a super class cannot be accessed from derived
classes.

Q48) Create a class Account with two overloaded constructors. First constructor is used for initializing,
name of account holder, account number and initial amount in account. Second constructor is used for
initializing name of account holder, account number, addresses, type of account and current balance.
Account class is having methods Deposit (), Withdraw (), and Get_Balance().Make necessary assumption
for data members and return types of the methods. Create objects of Account class and use them

Q49) Write a program in Java with class Rectangle with the data fields width, length, area and color .The
length, width and area are of double type and color is of string type .The methods are set_ length () ,
set_width (), set_ color(), and find_ area (). Create two object of Rectangle and compare their area and
color. If area and color both are same for the objects then display “Matching Rectangles” otherwise
display “Non matching Rectangle”.

Q50) Write a java program to implement final keyword with respect of class , method & data members?

Q51) Write a java program to demonstrate user of super & this keyword?

Q52) Write a Program that illustrates the Handling of predefined exceptions.

Q53) Write a Program that illustrates the Handling of user defined exceptions.

You might also like