40. Which of the following is/are true?
A. A static method may be overridden by a static method.
B. A static method may be overriden by a non-static method.
C. A non-static method may be overridden by a static method.
D. A non-static method may be overridden by a final non-static method.
My Answers are A ,D
Answers in the Book : D
Reason in book: A&B are false because static methods may not be overriden;
My sample to prove my answer is
import java.io.*;
class
Test {
public static void trial() { System.out.println("Class Test");}
}
public class T extends Test
{
public static void trial() { System.out.println("Class T");}
public static void main (
String[] args){
T t = new T();
t.trial();
}
}
The above code compiles and runs to print Class T....
Am I misinterpretting the answer?
Jignesh