zizi21
asked on
overriding
hi,
in my superclass, i have a method called void protected print(),
this is strange but in my subclass, i am able to overide the protected method with either protected and public.
public class parent{
protected void print(){
System.out.println("In parent");
}
}
public class child extends parent{
public void print()
{
System.out.println("In child");
}
}
however, in parent i have public print and i try to override it protected, i get error: "print() in child cannot override print() in parent; attempting to assign weaker access privileges; was public
in my superclass, i have a method called void protected print(),
this is strange but in my subclass, i am able to overide the protected method with either protected and public.
public class parent{
protected void print(){
System.out.println("In parent");
}
}
public class child extends parent{
public void print()
{
System.out.println("In child");
}
}
however, in parent i have public print and i try to override it protected, i get error: "print() in child cannot override print() in parent; attempting to assign weaker access privileges; was public
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER