can abstraction be used in multilevel inheritance code example
Example 1: how u can achieve multiple inheritances
Multiple inheritance in Java programming is achieved or
implemented using interfaces. Java does not support multiple
inheritance using classes.
In simple term, a class can inherit only one class and multiple
interfaces in a java programs. In java terminology, we can say that
“A class can extend only one class but it can implement
multiple interfaces.”
Example 2: java program to demonstrate multilevel inheritance
Class X
{
public void methodX()
{
System.out.println("Class X method");
}
}
Class Y extends X
{
public void methodY()
{
System.out.println("class Y method");
}
}
Class Z extends Y
{
public void methodZ()
{
System.out.println("class Z method");
}
public static void main(String args[])
{
Z obj = new Z();
obj.methodX();
obj.methodY();
obj.methodZ();
}
}