nerdexam
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)
  • A
    2% (1)
  • B
    2% (1)
  • C
    79% (37)
  • D
    4% (2)
  • E
    13% (6)

Community Discussion

No community discussion yet for this question.

Full 1Z0-850 Practice