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

Lab Assignment - PCC-CS593

Object oriented programming practice sheet

Uploaded by

mondalasrof067
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)
16 views5 pages

Lab Assignment - PCC-CS593

Object oriented programming practice sheet

Uploaded by

mondalasrof067
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

FUTURE INSTITUTE OF ENGINEERING AND MANAGEMENT

Department of Computer science and Engineering( Data Science)

LAB ASSIGNMENT
Subject: OOP Lab Sub Code: PCC-CS593

( IT 891)

Assignment-1
Objective:
The objective of this assignment is to learn how to write Simple JAVA Program.

1. Write a JAVA Program of Sum of Series for a given x and n (1+x+x2+x3+x4+……up to nth
terms)
2. Write a program in Java to find the reverse of a given integer number (take input using
command-line argument).
3. Write a program in Java to find the factorial of a given integer number using Recursion
(take input using command-line argument).
4. Write a JAVA program to sort n numbers (take input using command-line argument).

Assignment-2
Objective:
The objective of this assignment is to learn Classes and Objects concept.

5. Create a class called Board that contains two instance variables length and width of integer
type and a void method for calculating surface area of the board. Use them from main
method declared in different class (take input using command line argument).
6. Write a java program to find out the multiplication of two complex number (take input
using Scanner class).
7. Define a stack that uses one linear array and counter to notice number of items in stack.
Define member function corresponding to PUSH & POP operations including overflow and
underflow situation relevantly (Menu based).
Assignment-3
Objective:
The objective of this assignment is to learn Constructor & Method overloading concept.

8. Design a class to represent a Bank Account. Include the following things:


Fields
❖ Name of the depositor
❖ Account number
❖ Type of account
❖ Balance
Constructor
❖ To initialize an account
FUTURE INSTITUTE OF ENGINEERING AND MANAGEMENT
Department of Computer science and Engineering( Data Science)

LAB ASSIGNMENT
Subject: OOP Lab Sub Code: PCC-CS593

( IT 891)
Operations
❖ To deposit an amount
❖ To withdraw an amount from account
❖ To display the name and balance
❖ Mini statements of at least last 10 transactions
9. Create a class called Time that has separate integer member data for hour, minute and
second. One constructor should initialize these data to zero and another should initialize it
to fixed values. A main ( ) method should create three Time objects; among these, two
should be initialized by parameterized constructor and remaining one with default
constructor. Then it should add the value of two initialized objects together, storing the
result in a third Time type object (take input using scanner class).

10. Create a class named Shape. Make Circle, Triangle and Rectangle as object of the Shape
class and calculate their area by concept of constructor overloading (take input using
scanner class).

Assignment-4
Objective:
The objective of this assignment is to learn Inheritance concept.

11. Assume that a bank maintains two kinds of account for its customers, one called savings
account and other called current account. The savings account provides compound interest
and withdrawal facilities but no cheque book facility. The current account provides cheque
book facility but no interest. Current account holders should also maintain a minimum
balance (say Rs. 1000) and if the balance falls below this level a service charge is imposed
(say Rs. 100).

Create a class Account that stores customer name, account number and type of account.
From this class derive two classes Curr_Acct and Savn_Acct respectively to make them
more specific to their requirements. Include the necessary methods to achieve the
following tasks:

❖ Accept deposit from a customer and update the balance.


❖ Display the balance.
❖ Compute and deposit interest.
❖ Permit withdrawal and update the balance.
❖ Check for min. balance, impose penalty, if necessary, and update the balance.
Do not use any constructors. Use methods to initialize the class members.
FUTURE INSTITUTE OF ENGINEERING AND MANAGEMENT
Department of Computer science and Engineering( Data Science)

LAB ASSIGNMENT
Subject: OOP Lab Sub Code: PCC-CS593

( IT 891)

Assignment-5
Objective:
The objective of this assignment is to learn static, inner class & Method overriding concept.

12. Show that static block execute before any object creation.
13. Show that static blocks are execute in order of inheritance.
14. Create a class with an inner class that has no default constructor (one that take arguments).
Create a second class with an inner class that inherits from the first inner class.
15. Consider an example of book shop which sells books and video tapes. These two classes
inherited from the super class called media. The media class has data member such as title
and publications. The book class has data members for storing number of pages in a book
and the tape class has the playing time in tape. Each class will have member function such
as read() and show().Write a programs which models the class hierarchy for book shop.
Assignment-6
Objective:
The objective of this assignment is to learn Abstract Class & Interface concept.

16. 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.
17. Create two interface, each with one method, inherit a new interface from the two, adding a
new method. Create a class by implementing the new interface also inheriting from a
concrete class . Now write three methods, each of which takes one of the three interface as
an argument. In main() create an object of your class and pass it to each of the methods.
Assignment-7
Objective:
The objective of this Assignment is to learn Package concept.

18. Write a Java code to create a package named “testpackage”, create a class named “Add”
under this package which contains a method named”display”. Import this package in
another Java program
19. Create an interface with at least one method in its own package. Create a class in a separate
package. Add a protected inner class that implements the interface. In a third package,
inherit from your class and inside a method, return an object of the protected inner class
up-casting to the interface during the return.
FUTURE INSTITUTE OF ENGINEERING AND MANAGEMENT
Department of Computer science and Engineering( Data Science)

LAB ASSIGNMENT
Subject: OOP Lab Sub Code: PCC-CS593

( IT 891)
Assignment-8
Objective:
The objective of this assignment is to learn Strings & StringBuffer concept.
20. Write a method called delete (String str, int m) that returns the input string with the m-th
element removed.
21. Write a program in Java which can sort n words in lexicographical order.
22. Write a java program to generate Histogram of a set of characters of a given string.
23. Write a java program to replace all instances of one substring by another substring of a given
string without using replace method of String class.
Assignment-9
Objective:
The objective of this Assignment is to learn Exception Concept.

24. Define an object reference and initialize it to null. Try to call a method through this reference.
Now wrap the code in a try-catch clause to catch the exception.
25. Write a program that takes two numbers and string as command line argument and prints the
reverse of the substring of the string specified by the two numbers. The program should handle
all possible exception that may arise due to bad inputs.
Example, In command line argument, if user types java classname cookie 1 4, the output should
be 'ikoo'.

26. Create your own exception class using extends keyword. Write a constructor for this class that
takes a String argument and store it inside object with a String reference. Write a method that
prints out the stored String. Create a try-catch clause to exercise your new exception.

Assignment-10
Objective:
The objective of this Assignment is to learn Thread & Multi-Threading Concept.

27. Define a thread called “PrintTextThread” for printing text on command prompt for n number of
times. Create three threads and run them. Pass the text and n as parameters to the thread constructor.
Example:
i. First thread prints “I am in FY” 10 times
ii. Second thread prints “I am in SY” 20 times
iii. Third thread prints “I am in TY” 30 times
28. Write a program to show how three thread manipulate same stack , two of them are pushing
elements on the stack, while the third one is popping elements off the stack.
29. Write a java program to implement producer consumer problem using inter thread communication.
FUTURE INSTITUTE OF ENGINEERING AND MANAGEMENT
Department of Computer science and Engineering( Data Science)

LAB ASSIGNMENT
Subject: OOP Lab Sub Code: PCC-CS593

( IT 891)
Assignment-11
Objective:
The objective of this assignment is to learn Applet Concept.

30. Programs of implementing PARAM concept using Applet.


31. Create a moving banner which moves a string from left to right.
32. Write a program to create an applet that contains a text box to show time. The time should be
displayed in the hh:mm:ss format. The thread should start when the user clicks the Start button and
stop when the user clicks the stop button. Initialize the values to current time.
Assignment-12
Objective:
The objective of this Assignment is to learn AWT & Swing Concept.

33. 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.
34. Implement a four functions(i.e. add, subtract , multiplication, division ) Calculator with JButton &
JTextField using Swing.

You might also like