exam questions

Exam 1z0-811 All Questions

View all questions & answers for the 1z0-811 exam

Exam 1z0-811 topic 1 question 77 discussion

Actual exam question from Oracle's 1z0-811
Question #: 77
Topic #: 1
[All 1z0-811 Questions]

Given the code fragment:



Which modification enables the code to print true?

  • A. At line n2, insert: System.out.println(c1.equals (c2));
  • B. At line n1, override the equals о method from the object class and, at line n2, insert :
    System.out.println(c1.equals(c2));
  • C. At line n2, insert: System.out.println(c1.compareTo(c2));
  • D. At line n1, override the hashCode() method from the Object class and, at line n2, insert :
    System.out.println(c1.compareTo(c2));
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
brunojee
2 months, 3 weeks ago
Selected Answer: B
In addition to overriding the equals method, you need to compare the attribute "name".
upvoted 1 times
...
brunojee
2 months, 3 weeks ago
Selected Answer: B
In addition to overriding the equals method, you need to compare the variable name.
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago