SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
FACULTY OF ENGINEERING AND TECHNOLOGY
SCHOOL OF COMPUTING
DEPARTMENT OF NETWORKING AND COMMUNICATIONS
21CSC203P ADVANCED PROGRAMMING PRACTICE
Week 6 – Tutorial Assignment
Object-Oriented Programming Paradigm
1. Write a Java program to create a class called "Person" with a name and age attribute. Create
two instances of the "Person" class, set their attributes using the constructor, and print their
name and age.
2. Write a Java program to create class called "TrafficLight" with attributes for color and
duration, and methods to change the color and check for red or green.
3. Write a Java program to perform arithmetic operations using method overloading.
4. Write a Java program to create a class called Employee with methods called work() and
getSalary(). Create a subclass called HRManager that overrides the work() method and
adds a new method called addEmployee().
5. Write a Java program to create a class called Shape with methods called getPerimeter() and
getArea(). Create a subclass called Circle that overrides the getPerimeter() and getArea()
methods to calculate the area and perimeter of a circle.
6. Write a Java program to create an interface Sortable with a method sort() that sorts an array
of integers in ascending order. Create two classes BubbleSort and SelectionSort that
implement the Sortable interface and provide their own implementations of the sort()
method.
7. Write a Java program to create an interface Resizable with methods resizeWidth(int width)
and resizeHeight(int height) that allow an object to be resized. Create a class Rectangle
that implements the Resizable interface and implements the resize methods.
8. Write a Java program to create an interface Flyable with a method called fly_obj(). Create
three classes Spacecraft, Airplane, and Helicopter that implement the Flyable interface.
Implement the fly_obj() method for each of the three classes. Hint :- fly_obj definition –
prints the particular object is flying.
9. Write a Java program to have the arithmetic functions defined in different user-defined
packages and incorporate all the packages and perform the function in a single class.
10. Create two different packages to compute bubblesort and selection sort. Write a Java
program to implement sorting functions in a single class.