1)Inheritance will only work when the child class's constructor is accessible(public)
When Inheritance is applied all the methods in Parent class's are copied into child class
Class A
{
Members
}
Class B:A
{
Consuming members of A
}
A is the Super class or Parent Class
2)When Parent and Child both have constructors
Parent Class constructor is called first
3)Parent Class can not access Child class members
4)We can initialize Parent Class variable by using a child class instance
Class A
{
A a;
B b=new B();
a=b; //b is an instance variable and a is class variable
}
When Inheritance is applied all the methods in Parent class's are copied into child class
Class A
{
Members
}
Class B:A
{
Consuming members of A
}
A is the Super class or Parent Class
2)When Parent and Child both have constructors
Parent Class constructor is called first
3)Parent Class can not access Child class members
4)We can initialize Parent Class variable by using a child class instance
Class A
{
A a;
B b=new B();
a=b; //b is an instance variable and a is class variable
}