Java supports Multi Level Inheritance but Not Multiple Inheritance.
class One
{
void Ofun()
{
System.out.println("This is class One");
}
}
class Two extends One
{
void Tfun()
{
System.out.println("This is class Two");
}
}
class Three extends Two
{
void Thfun()
{
System.out.println("This is class Three");
}
}
public class Test
{
public static void main(String args[])
{
Three t1 = new Three();
t1.Ofun();
t1.Tfun();
t1.Thfun();
}
}
The above thing is called Multiple Inheritance in which the base class inherites to its derived class and the derived class inherites to its derived class and so on.
But In Java, Multiple inheritance is not supported instead their is a concept of Interface.
Comments
Post a Comment