This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes true/false about  core java funde Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "true/false about  core java funde" Watch "true/false about  core java funde" New topic
Author

true/false about core java funde

vicky ma
Ranch Hand

Joined: May 13, 2009
Posts: 38
A private static method can be called only within other static methods in class X.
A non-static public final method in class X can be overridden in any subclass of X.
A public static method in class X can be called by a subclass of X without explicitly referencing the class X.
A method with the same signature as a private final method in class X can be implemented in a subclass of X.
A protected method in class X can be overridden by a subclass of A only if the subclass is in the same
package as X.




which of this are true ?

last 1 is too complicated
please explain in detail !
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

vicky ma wrote:
[/b] A protected method in class X can be overridden by a subclass of A only if the subclass is in the same
package as X.
last 1 is too complicated
please explain in detail !


this is false since protected is visible to the subclass across the packages
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

vicky ma wrote:A private static method can be called only within other static methods in class X.

false, non-static members of class X can also call static private method of class X

vicky ma wrote:A non-static public final method in class X can be overridden in any subclass of X.

false, final methods that are inherited cannot be overridden.

vicky ma wrote:A public static method in class X can be called by a subclass of X without explicitly referencing the class X.

True, the sub-classes of X will have direct access to static methods of class X

vicky ma wrote:A method with the same signature as a private final method in class X can be implemented in a subclass of X.

True, the method won't be inherited so it can be overridden.
Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 417
Ankit Garg wrote:
vicky ma wrote:A method with the same signature as a private final method in class X can be implemented in a subclass of X.

True, the method won't be inherited so it can be overridden.

Just an observation: if the method is not inherited, so it's not overridden. It's just another method method with the same signature.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

"funde" is not a real word. Please use only real words when posting. Please read this for more information.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: true/false about core java funde
 
Similar Threads
A private final method in class X can be implemented in subclass of X, Why?
method overriding with different access specifier
mock question
Private method overriden...
Clarification