_ _ _____________________________ _ _ <br /> <br /> * SCJP 5.0
_ _ _____________________________ _ _ <br /> <br /> * SCJP 5.0
Originally posted by Girish Nagaraj:
[QB]1)Suppose there is a static method in the class A. Another class B extends class A. Here, the static method in A is not inherited by the class B. So, you cannot override it. However you can have a static method which has the same signature as the one in the parent class. This is called as hiding.
a)the static method in A is not inherited by the class B-->WRONG.
b)the static method in A is not inherited by the class B ONLY if their is similer static method in class B which has same method prototype as that of static method in the superclass(In which case static method in superclass is hidden).
Can you please tell me why static methods cannot be overridden
Originally posted by Girish Nagaraj:
1)Hint 1:static methods(also called class methods) belongs to class and not to any particular instance.
Originally posted by Ganesha Kumar:
If static methods belog to the class, then why are they inherited.
Originally posted by faisal usmani:
No static methods are not inherited, it is a class property and not an object's property, that is why we can also call a static method without creating an instance of the class
Let nothing stop you! Not even this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|