MCQs > IT & Programming > Java > Result of compiling and running the given code? public class Test75 { public static void main(String[] args) { System.out.println(new A(){{}}.toString()); } } class A { public String toString() { return getClass().getName(); } }

Java MCQs

What is the result of compiling and running the given code? public class Test75 { public static void main(String[] args) { System.out.println(new A(){{}}.toString()); } } class A { public String toString() { return getClass().getName(); } }

Answer

Correct Answer: It compiles, but throws NullPointerException at run-time.

Explanation:

Note: This Question is unanswered, help us to find answer for this one

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

More Java MCQ Questions

search

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it