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 Restrictions in hibernate?

1 Answers   Bally Technologies,


there are N number of matchboxes numbered 1...N.each matchbox contain various number of stick.Two player can alternatevely pick some amount of stick from the higest stick containing box . The player is condidered win if there is no stick after his move.Find the final move so that the move player win. Note:In case the number of stick is equal ,pick the stick from the higest numbered box.

0 Answers   Manhattan,


What is method and methodology?

0 Answers  


What is the difference between a Window and a Frame?

6 Answers   Infosys, ProKarma,


What is the effect of keeping a constructor private?

0 Answers  






garbate collector(GC)?

4 Answers  


why java does not support mulitple inheritance directly?

3 Answers   TCS,


Can we restart a dead thread in java?

0 Answers  


What is meant by method?

0 Answers  


What is a stream? what are the different types and classes of Streams?

2 Answers  


what is thread? What are the high-level thread states? Or what are the states associated in the thread? : Java thread

0 Answers  


What is generics in java interview questions?

0 Answers  


Categories