OOP's Lab Programs Questions
OOP's Lab Programs Questions
1 1. https://www.hackerrank.com/challenges/java-loops-i/problem
2. KLEF FED office has 2 files, CSE.txt and ECE.txt. Both files have 3
columns- ID, Name and Mobile number of CSE and ECE students,
respectively. The task is to read data from both files and store in a file
students.txt and print the data of students.txt
4 1. Design a class named Account that contains:
A private int data field named id for the account (default 0).
A private data field named balance for the account (default 0).
A no-arg constructor that creates a default account.
A constructor that creates an account with the specified id and
initial balance.
The accessor and mutator methods for id, balance.
Mutators return Boolean (If all the fields must be +ve, return true,
else false)
A method named withdraw that withdraws a specified amount
from the account.
A method named deposit that deposits a specified amount to the
account.
A method to print the details of Account
Analyze each element in the collection and output the date represented in
the form 29th October 1999.
6 1. A company wants to digitalize their manual records of the employee
details (Employee ID, Employee name, Employee Department). If all the
three fields are given, use the given details. If not, use the default values.
(Use Constructor Overloading)
Default values are:
ID: 0
Name: #
Department: #.
Write mutators and accessors and method to print Employee data in the
above format.
Write a menu driven main program to perform the following operations:
a) Create new Employee record
b) Update name based on ID
c) Print All Employees
d) Print Department Specific employees given department
2. https://www.hackerrank.com/challenges/java-substring/problem
7 1.Develop a program that creates a generic Shape class with attributes
fillColor, borderColor, fill (Boolean type) and border width. The classes
Rectangle, Circle must inherit Shape. Rectangle has length and width as
attributes and circle with radius as attribute. Also add the corresponding
getters and setters in each of the classes. Use appropriate access specifiers.
Instantiate the objects and test the code.
2. Enhance the above Q1 hierarchy such that Shape is the general class,
inherited by TwoDShape and ThreeDShape class, and Rectangle, Circle
inherits the TwoDShape, Cuboid extends the ThreeDshape.
and side3.
ter of this
triangle.
follows:
2. Design a class named Person and its two subclasses named Student and
Employee. Make Faculty and Staff subclasses of Employee. A person has
a name, address, phone number, and email address. A student has cgpa as
attribute. An employee has salary, and date hired as attributes. A faculty
member has designation as attribute. A staff member has hoursWorked as
attribute. Draw the UML diagram for the classes and implement them.
Write a test program that creates a Person, Student, Employee, Faculty, and
Staff, and invokes their accessors and a method to print the data.
9 1. Define an abstract base class Point that includes protected data members
for the (x, y) position of a shape, a public method to move a shape, and a
public abstract method show() to output a shape. Derive subclasses- line,
circle, and rectangle. You can represent a line as two points, a circle as a
center and a radius, and a rectangle as two points on diagonally opposite
corners. Test the classes by selecting ten random objects of the derived
classes, and then invoking the show() method for each.
2. https://www.hackerrank.com/challenges/java-abstract-class/problem
10 1. https://www.hackerrank.com/challenges/java-exception-handling-try-
catch/problem
2. Write a program for developing an interactive application for a simple
calculator using event-driven programming.