What is the result?

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.print(“== “);
22. if (d1.equals(d2)) System.out.println(“dot =”);
23. }
24. }
What is the result?

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.print(“== “);
22. if (d1.equals(d2)) System.out.println(“dot =”);
23. }
24. }
What is the result?

A.
== dot =

B.
Compilation fails.

C.
dot =

D.
No output is produced.

E.
==

F.
The result is unpredictable.



Leave a Reply 0

Your email address will not be published. Required fields are marked *