0% found this document useful (0 votes)
13 views

OOP Assignment

Uploaded by

gfxhdgntd525
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

OOP Assignment

Uploaded by

gfxhdgntd525
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

OBJECT ORIENTED PROGRAMMING

ASSIGNMENTS
LAB TASK 01:
Create a class named ‘Shape’ with a method to print "This is shape”. Then create two other classes
named

Rectangle’, Circle" inheriting the Shape class, both having a method to print “This is rectangular
shape" and
“This is circular shape” respectively. Create a subclass Square’ of ‘Rectangle’ having a method to
print

"Square is a rectangle". Now call the method of ‘Shape’ and Rectangle’ class by the object of
‘Square’ class.
LAB TASK 02:
Create a class with a method that prints "This is parent class” and its subclass with another
method that
prints "This is child class". Now, create an object for each of the class and call
1- method of parent class by object of parent class.
2 method of child class by object of child class
3- method of parent class by object of child class

LAB TASK 03:


Create a class named ‘PrintNumber’ to print various numbers of different datatypes by
creating different methods with the same name ‘printn’ having a parameter for each
datatype.

LAB TASK 04:


Create a class to print the area of a square and a rectangle. The class has two methods with the
same name but different number of parameters. The method for printing area of rectangle has
two parameters which are length and breadth respectively while the other method for printing
area of square has one parameter which is side of square.
LAB TASK 05:
A boy has his money deposited $1000, $1500 and $2000 in banks-Bank A, Bank B and Bank C
respectively. We have to print the money deposited by him in a particular bank.
Create a class 'Bank' with a method 'getBalance' which returns 0. Make its three subclasses
named 'BankA', 'BankB' and 'BankC' with a method with the same name 'getBalance' which
returns the amount deposited in that particular bank. Call the method 'getBalance' by the object
of each of the three banks.
LAB TASK 06:
Write a program which contain 3 methods with the same named ’printChar’. First method

takes no argument and print 45 asterisk (*) in a single line. Second method takes char as an
argument and display specifies character 45 times. Third method takes char and number as
an arguments and display specifies number of copies of specified character.
LAB TASK 07:

Create an abstract class Browser having field version and an abstract method
opentab(), Now create a class Firefox which will implement the opentab() method, create
another class GoogleChrome which will also implement the opentab() method. In the main
class call the opentab() method for both Firefox and GoogleChrome class.
LAB TASK 08:

Create an interface Animal and declare abstract method eat() and travel(). Now create three
classes Reptiles, birds and Fish for implementing these methods.

You might also like