Link to home
Start Free TrialLog in
Avatar of zizi21
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
ASKER CERTIFIED SOLUTION
Avatar of basicinstinct
basicinstinct
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zizi21
zizi21

ASKER

thank you very much.. Studying for exam and all this is helping a lot . God bless.