Respuesta :
Answer:
The explanation of the code is given below in explanation section. The code given in the question is of Java lanaguage. This code has three different classes. Class One has print method, while Class Two has extend the feature of class one and override the print method. Class Three also extend the class two features and override the print() method. However, it is noted that you can declare object of same name for these classes. Because due to inheritance. If you want to declare object of all classes, then you have to declare different objects for these classes.
The code with explanation is give below in explanation section
Explanation:
class One {
public void print()
{ System.out.println("One"); }
}
class Two extends One {
public void print() { System.out.println("Two"); }
}
class Three extends Two {
public void print() { System.out.println("Three"); }
}
public class Print{
public static void main(String []args){
Two object1= new Two();
object1.print();// will print two
//if you want to print class one print method
//then you have to create class one object.
One object2=new One();//declare class one object
object2.print();//it will print one
/* if you want to call class three print() method, then you have to declare class 3 object.*/
Three object3=new Three();//class three objecte declaration
object3.print();
}
}