Answers for "create single level inheritance where both base and derieved classes will have three methods with same names in both the classes. and the main function is given along with output. Design the base and derieved classes."

0

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(); //calling grand parent class method
     obj.methodY(); //calling parent class method
     obj.methodZ(); //calling local method
  }
}
Posted by: Guest on September-08-2020

Code answers related to "create single level inheritance where both base and derieved classes will have three methods with same names in both the classes. and the main function is given along with output. Design the base and derieved classes."

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language