There are two questions in the Sybex Virtual Trainer that in my view contradict each other. Or I might not have understood overriding...
Question 1:
What happens when you attempt to compile and run the following code?
1. class A { static void foo() {}; }
2. class B extends A { public static void foo() {}; }
Options:
a) Compiler error at line 1
b) Compiler error at line 2
c) No compiler error
Sybex says that c) -> A static method may only be overridden by another static method; that is what is done here, so the code compiles.
Question 2:
Which of the following is/are true?
A. A static method may be overridden by a static method.
B. ...
Sybex says that A is
not true, because "static methods may not be overridden".
Now, may static methods be overridden or not?! I'm a bit confused...
Thanks for your help!
Ulrich