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).

Answers were Sorted based on User's Feedback



when asub class inherits a super class and overrides a public method of super class in sub class(pu..

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

when asub class inherits a super class and overrides a public method of super class in sub class(pu..

Answer / ravikiran

the access specifies sould not me more restrictive in a
subclass.

Is This Answer Correct ?    1 Yes 0 No

when asub class inherits a super class and overrides a public method of super class in sub class(pu..

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

More Core Java Interview Questions

What is I/O Filter?

2 Answers   TCS, WAX,


How infinite loop is declared?

0 Answers  


What is comparable and comparator interface? List their differences

0 Answers  


is memory to the abstract class allocated ..or objects not instantiated

7 Answers   Synechron, TCS,


What is google full form?

0 Answers  






What is escape analysis algorithm in JVM and how garbage collection actually worked n how it transfer the objects from one kind of space to other?

0 Answers  


What is the difference between error and an exception?

0 Answers  


What is the static keyword?

0 Answers  


When is the garbage collection used in Java?

0 Answers   BirlaSoft,


Tell us something about an iterator.

0 Answers  


What is java util function?

0 Answers  


Which is better ascii or unicode?

0 Answers  


Categories