when asub class inherits a super class and overrides a
public method of super class in sub class(public method in
super class).
why these methods needs to be public in sub class.
(otherwise compile time error).

Answer Posted / sushila

if super class method is public, then override method should
be public.

override method will take same access specifier or expanded one.

the order of access specifier is
private > default > protected > public

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can static methods access instance variables in java?

581


extending thread class or implementing runnable interface. Which is better? : Java thread

573


What is equlas() and hashcode() contract in java? Where does it used?

625


Does substring start with 0?

565


Name few java.lang classes introduced with java 8 ?

548






Can you make a constructor final in Java?

636


What classes of exceptions may be thrown by a throw statement?

536


How to instantiate static nested classes in java?

570


What is a copy constructor in java?

588


What is the difference between abstract class and interface1? What is an interface?

568


Can you inherit a constructor java?

583


What is fundamental datatype?

537


What are register variables what are the advantages?

458


What are the differences between abstract class and interface?

517


What is a short in java?

514