Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

true/false about core java funde

 
vicky ma
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"funde" is not a real word. Please use only real words when posting. Please read this for more information.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic