What is the result?

Given:
11. class Cat {
14. public static void main(String [] args) {
15. Cat c1 = new Cat();
16. Cat c3 = new Cat();
17. Cat c2 = c1;
18. Cat c4 = c3;
19. c1 = c4;
20. c4 = c2;
21. if (c1 == c2) System.out.print(“c1 == c2 “);
22. if (c1 == c3) System.out.print(“c1 == c3 “);
23. }
24. }
What is the result?

Given:
11. class Cat {
14. public static void main(String [] args) {
15. Cat c1 = new Cat();
16. Cat c3 = new Cat();
17. Cat c2 = c1;
18. Cat c4 = c3;
19. c1 = c4;
20. c4 = c2;
21. if (c1 == c2) System.out.print(“c1 == c2 “);
22. if (c1 == c3) System.out.print(“c1 == c3 “);
23. }
24. }
What is the result?

A.
The output is unpredictable.

B.
c1 == c2 c1 == c3

C.
No output is produced.

D.
c1 == c3

E.
c1 == c2



Leave a Reply 0

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