Which statement about Java interfaces is INCORRECT according to 2024 specifications?
AInterfaces can have static methods
BInterfaces can have default methods
CInterfaces can have private methods
DInterfaces can be instantiated directly
Correct Answer:
D. Interfaces can be instantiated directly
EXPLANATION
Interfaces cannot be instantiated directly. Since Java 8, interfaces can have static and default methods, and since Java 9, they can have private methods.
Which of the following demonstrates proper method overloading in Java?
Apublic void display() { } and public int display() { }
Bpublic void display(int a) { } and public void display(int b) { }
Cpublic void display(int a) { } and public void display(String a) { }
Dpublic void display() { } and public void display() { return 5; }
Correct Answer:
C. public void display(int a) { } and public void display(String a) { }
EXPLANATION
Method overloading requires different parameter types or number of parameters. Options A and D have different return types (not valid for overloading), and option B has the same signature with different parameter names (not overloading).