Oracle
1Z0-851 · Question #92
Given: 01. interface TestA { String toString(); } 02. 03. public class Test { 04. public static void main(String[] args) { 05. System.out.println(new TestA() { 06. public String toString() { return…
The correct answer is A. test. See the full explanation below for the reasoning.
Question
Given: 01. interface TestA { String toString(); } 02. 03. public class Test { 04. public static void main(String[] args) { 05. System.out.println(new TestA() { 06. public String toString() { return "test"; } 07. }); 08. } 09. } What is the result?
Options
- Atest
- Bnull
- CAn exception is thrown at runtime.
- DCompilation fails because of an error in line 1.
- ECompilation fails because of an error in line 4.
- FCompilation fails because of an error in line 5.
How the community answered
(55 responses)- A84% (46)
- B2% (1)
- C2% (1)
- D4% (2)
- F9% (5)
Community Discussion
No community discussion yet for this question.