Q1 Select three correct statements.
(1) A static method may override another static method
(2) A static method cannot override a non-static method
(3) A non-static method cannot override a static method
(4) A non-static method may be overloaded by a static method
(5) A synchronized method cannot be overridden
Answer : 2,3,4
Explanation :
Overriding is for non-static methods and hiding is for static methods. So the following statements are the only true statements about hiding and overriding:
a static method (in a subclass) may hide another static method (in a superclass)
a static method (in a subclass) cannot hide a non-static method (in a superclass)
a non-static method (in a subclass) may override another non-static method (in a superclass)
a non-static method (in a subclass) cannot override a static method (in a superclass)
Sunday, June 1, 2008
Latest Dumps SCJP
Posted by javaexpert at 10:14 PM 0 comments
Labels: Static methods and varaibles
Subscribe to:
Posts (Atom)