Object Oriented Programming Using Java Lab Manual (4+2)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

MBIT

2150704 - OBJECT ORIENTED PROGRAMMING USING JAVA


Lab Manual
(4+2)
IT
AY: 2018-19; Semester: V
Lab Manual
1. Path, Class path and Java Syntax:

1) Learn the significance of path & class path to execute JAVA applications
using command prompt.
2) Implement a program to print a statement on the console.
3) Add two integer numbers and print the result
4) Find out the difference between print and println methods.

2. Java Language Basics:

1) Implement a program to print Fibonacci series up to given no. use various


control statements.
2) Implement a program to find factorial of given no using recursion.
3) Program to find prime numbers between a given ranges.
4) Program to reverse an n-digit number.

3. Arrays, Casting & Operators:

1) Implement a program that creates & initialize 5 elements of a 1-D array & a
2-D array of type int & display it.
2) Create arrays of 5 item. Pass item name, qty and rate. Calculate and display
net amount for each item. Also display item having highest net amount.
3) Implement a JAVA program that supports automatic type casting in JAVA.
4) Implement a JAVA program that supports type casting of incompatible
types.

4. Classes & Objects:

1) Create a class called stack having two private members (array of integer,
tos) & two methods called push () & pop (). Create class DemoStack having
main () method. In that create stack object with different array size and then
push & pop the elements from stack.

Dr. Krunal N. Patel


(IT Department )
2) Create a class Box. Define the values of width, height and length in
constructor called Box. Calculate the dimension and volume of the box.
3) Make a program to implement calculator which performs general
arithmetic operations like addition, multiplication etc. Pass values and type
of operation from command line argument.

5. Method Overloading, Overriding, Inheritance

1) Write a Java program to implement function overloading.


2) Create class called Shape having private data member of type String & one
method called area (). Create a class Square, Rectangle & Triangle that are
extending class Shape. Override area () method in square, rectangle &
triangle. Experiment run time polymorphism in main program.
3) Write a Java program to demonstrate the nested class.
4) Write a simple JAVA program to implement Dynamic Dispatch

6. Interface & Abstract class :

1) Create a class Shape make it abstract, create one method abstract method
area() override it to calculate area of rectangle and Triangle.
2) Create an interface Area. Create compute() method and compute the area
of Rectangle and circle and display it using display method().

7. Packages:

1) Write a simple JAVA program to perform calculator operation using package


& interface.
2) Create package P. Create two class Addition and Subtraction into P. Create
another package Q and calculate the addition and Subtraction of two
numbers.
3) Create package Account and calculate the display the name and balance of
the given customer which ha balance less than 0.

8. Exception Handling:

1) Write a JAVA program that generate the AirhtmaticExaception and


ArrayIndexOutOfBoundException.
2) Write a JAVA program to demonstrate finally block.
3) Write a JAVA program to implement custom Negative Number exception.
9. File I/O:

1) Write a JAVA program to perform character read operation.


2) Write a JAVA program to perform character write operation.
3) Write a JAVA program to perform to create a new file and write data to
that file.

Dr. Krunal N. Patel


(IT Department )
4) Write a JAVA program to perform read and write operation using Random
Access File concept.
10.1 Multithreading:

1) Write a JAVA program to demonstrate thread.


2) Write a JAVA program to perform odd & even summation using thread.
3) Write a JAVA program to implement one producer & one consumer
problem using queue and thread.
4) Write a JAVA program to implement two producer and two consumer
problem using queue and thread.
11. Prepare a class diagram for given group of classes using multiplicity, generalization,
association concepts. And add at least 5-7 attributes and 3-5 operations for
particular class Page, Shape, Point, Line, Arc, Ellipse, Rectangle, Circle
12. Prepare a class diagram for given group of classes using multiplicity, generalization,
association concepts. And add at least 5-7 attributes and 3-5 operations for
particular class. City, Airport, Airline, Pilot, Flight, Plane, Seat, Passenger
13. Categorize the following relationships into generalization, aggregation or
association.
[A] A country has a capital city
[B] A dining philosopher uses a fork
[C] A file is an ordinary file or a directory file
[D] Files contains records
[E] A polygon is composed of an ordered set of points
[F] A drawing object is text, a geometrical object, or a group
[G] A person uses a computer language on a object
[H] Modems and keyboards are input/output devices
[I] Classes may have several attributes
[J] A person plays for a team in a certain year
[K] A route connects two cities
[L] A student takes a course from a professor
14. Prepare a state diagram for an interactive diagram editor for selecting and dragging
objects
15. Prepare a use case diagram and sequence diagram for a computer email system
16. Prepare an activity diagram for computing a restaurant bill, there should be charge
for each delivered item. The total amount should be subject to tax and service
charge of 18% for group of six and more. For smaller groups there should be a blank
entry. Any coupons or gift certificates submitted by the customer should be
subtracted
17. Prepare a sequence diagram for issuing a book in the library management system

Dr. Krunal N. Patel


(IT Department )

You might also like