//Test1.javaclass Vehicle { public int getRegistrationNumber() { return 1; }}class Car { public int getRegistrationNumber() { return 2; }}public class Test1 { public static void main(String[] args) { Vehicle obj = new Car(); System.out.println(obj.getRegistrationNumber()); }}
A. 1
B. 2
C. An exception is thrown at runtime.
D. Compilation error.
Answer:D
//Test1.javaclass Vehicle { public int getRegistrationNumber() { return 1; }}class Car { public int getRegistrationNumber() { return 2; }}public class Test1 { public static void main(String[] args) { Vehicle obj = new Car(); System.out.println(obj.getRegistrationNumber()); }}
A. 1 B. 2 C. An exception is thrown at runtime. D. Compilation error.