Oracle
1Z0-850 · Question #18
Given: 14. class Dog { 15. String name; 16. public static void main(String [] args) { 17. Dog d1 = new Dog(); 18. Dog d2 = new Dog(); 19. d1.name = "Aiko"; 20. d2.name = "Aiko"; 21. if (d1 == d2)…
The correct answer is C. dot =. See the full explanation below for the reasoning.
Question
Given:
14. class Dog {
15. String name;
16. public static void main(String [] args) {
17. Dog d1 = new Dog();
18. Dog d2 = new Dog();
19. d1.name = "Aiko";
20. d2.name = "Aiko";
21. if (d1 == d2) System.out.println("== ");
22. if (d1.equals(d2)) System.out.println("dot =");
23. }
24. }
What is the result?
Options
- A== dot =
- BCompilation fails.
- Cdot =
- DNo output is produced.
- E==
How the community answered
(47 responses)- A2% (1)
- B2% (1)
- C79% (37)
- D4% (2)
- E13% (6)
Community Discussion
No community discussion yet for this question.