Inheritance is a future of oops(Object Oriented Programming).it Used To Share The Properties of Class or a class drive from another one class is Called Inheritance. in Java Programming "extends" Keyword is used to inherit the class.
Syntax:
example,class A{
//member variables and function
}
class B extends class A
{
//member variables and function
}
class A{
void superclass()
{
System.out.println("super class");
}
}
class B extends class A
{
public static void main()
{
B b=new B();
b.superclass();
}
}
From The Above Java Programming Contains Two Classes Named As "A" and "B".class A contains a Member Method Named as "superclass()" and class B contains main method.then class B is Inherit(Extends) From class A.So We are call The method superclass from class B.
Comments
Post a Comment