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 / imtiyaz

The access specifier for the overriding method can allow
more but not less access than the overridden method.
For example, a protected method in the superclass can be
made public but not private

private, protected and public is Ascending order of access
modifiers depending upon the strength

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What should I import for arraylist in java?

504


How do you classify Dialog Box?

641


Explain the term virtual machine?

583


Is java call by value?

581


What is a singleton class in Java?

501






How is hashset defined in java?

517


Is singleton a bad practice?

571


Is it possible to write a regular expression to check if string is a number?

538


How do you format in java?

543


What do you mean by access modifier?

550


How do you convert boolean to boolean?

515


Explain the hierarchy of java exception classes?

588


What is replaceall in java?

541


1.IN CASE OF DYNAMIC METHOD DISPATCH WHY WE USE REFERENCE VARIABLE,WE CAN USE THE DIFFERENT DEFINED OBJECT DIRECTLY TO ACCESS THE DATA MEMBER AND MEMBER FUNCTION OF THAT RESPECTIVE CLASS?WHAT IS THE MAIN FUNCTION OF "REFERENCE VARIABLE" HERE?

3780


what state does a thread enter when it terminates its processing? : Java thread

590