I have three classes
public class Abc
{
public methAbc()
{
System.out.println("parent class method");
}
}
public class Xyz extends Abc
{
public methAbc()
{
System.out.println("overriden parent class method");
}
public methXyz()
{
System.out.println("child class method");
}
}
class Pqr
{
Xyz childObjChildRef = new Xyz();
Abc childObjParentdRef = new Xyz();
}
in the Pqr class what is the main difference in creating objects in different links
1: when holding an object in the same class reference ==>, then we can call all methods from the class
2: when holding an object in the link of the parent class ==>, then we can only call the overridden methods from the class
user1379280
source
share