Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

OOP Lab-III

1. Write a program that car inherits some fields and methods from vehicle class.
2. Write a program that DDU teacher inherits some properties and functionalities from DDU
employees.
3. Create class box and box3d. box3d is extended class of box. The above two classes going
to pull fill following requirement
❖ Include constructor.
❖ set value of length, breadth, height
❖ Find out area and volume.

Note: Base class and sub classes have respective methods and instance variables.

4. Write a program to create a class named shape. In this class we have three sub classes
circle, triangle and square each class has two-member function named draw () and erase ().
Create these using inheritance concepts
5. The super keyword [ differentiate members+ invoke superclass constructor]

// differentiate members with the same name // invoke superclass constructor


class Parent{ class Base{
String name;} int x;
public class Child extends Parent{ Base(int _x){
String name; x=_x;}}
public void display(){ public class Drived extends Base{
super.name="parent"; int y;
name="child"; Drived(int _x,int _y){
System.out.println(super.name+""+name);} super(_x);
public static void main(String args[]){ y=_y; }
Child c=new Child (); void display(){
c.display(); System.out.println("x="+x+"y="+y);}
}} public static void main(String args[]){
Drived d=new Drived(10,2);
d.display(); }}

➢ Write a java program that a student class inherits different fields and methods
from person class.
➢ Write a java program that computer science department inherits some courses
from different departments.

You might also like