OOP Assignment
OOP Assignment
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
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.