Inheritance

Property of parent class access in child classin inheritance

Child class access parent class property by using extends keyword

Types of inheritance

1)Single inhritance
2)Multilevel inheritance
3)Hybrid inheritance
4)Multipleinheritance

Single Inheritance

When one child class access property from only one parent class.

Example

College.java

//Parent class
class college{
 
   void bus(){
    System.out.println("It is compulsory");
   }
 }
          

student.java

//Child class
class student extends college{    //child class access parent class property by using extends keyword
                                  //Here student class access  college class property by using extends keyword
    void fees(){
	System.out.println("Pay before time");
	}

	public static void  main(String args[]){
	 student s=new student();
	 s.bus();                    // method bus() is declare in college class
	                             //student class access bus() method 
	 s.fees();
	
	}
}   
       

output:	
IT is compulsory     //this is output come from parent class
Pay before fees      //this is output come from child class
          

Address

Plot number-56/1
Near Gurudwara
LandMark :
Opposite A.N.D college
Govindpuri Metro station
New Delhi
Mobile number:
8826034620