Categories
Uncategorized

Hierarchal Inheritance

Simple program for Hierarchal inheritance import java.util.Scanner; class rectangle { double length,breadth,radius,heigth; Scanner a=new Scanner(System.in); void get() { System.out.println(“enter length and breadth:”); length=a.nextDouble(); breadth=a.nextDouble(); } void display() { double ar; ar=length*breadth; System.out.println(“Area of Rectangle:”+ar); } }

Categories
Uncategorized

Single Inheritance

Simple example of single inheritance import java.util.Scanner; class rectangle { double length, breadth; void get() { Scanner a= new Scanner(System.in); System.out.println(“enter lenght and breadth:”); length=a.nextDouble(); breadth=a.nextDouble(); } void display() { double ar; ar=length*breadth; System.out.println(“Area of Rectangle:”+ar); } } class square extends rectangle

Categories
Uncategorized

Multilevel Inheritance

Simple Example of Multilevel inheritance import java.util.Scanner; class rectangle { double length, breadth; void get() { Scanner a= new Scanner(System.in); System.out.println(“enter lenght and breadth:”); length=a.nextDouble(); breadth=a.nextDouble(); } void display() { double ar; ar=length*breadth; System.out.println(“Area of Rectangle:”+ar); } } class circle extends rectangle