exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 10 discussion

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

Given the code fragment:

What is the result?

  • A. Match 1
  • B. Match 2
  • C. No Match
  • D. A NullPointerException is thrown at runtime.
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

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
vic88
1 week, 6 days ago
Selected Answer: A
Match 1
upvoted 1 times
...
pedone_valerio
2 months, 2 weeks ago
public static void main(String[] args) { StringBuilder sb = new StringBuilder("Java"); String s = "Java"; if (sb.toString().equals(s.toString())) { System.out.println("Match 1"); } else if (sb.equals(s)) { System.out.println("Match 2"); } else { System.out.println("No Match"); } Answer A
upvoted 1 times
...
iheb07
7 months, 3 weeks ago
Answer A
upvoted 1 times
...
AhmadTechie
1 year ago
Answer is A. As sb.toString() => new string object gets created and String equals() method do content check
upvoted 1 times
...
arjunrawatirissoftware
1 year, 2 months ago
Answer- A
upvoted 1 times
...
Sezam
1 year, 3 months ago
The answer is A
upvoted 1 times
...
Ankit1010
1 year, 10 months ago
sb.toString() => converts it into String. and thereafter, using equals() method on String will do the value comparison. So, answer is A since the values are equal.
upvoted 3 times
...
willokans
2 years ago
Inconvertible type error between String "Java" and StringBuilder "Java". To resolve StringBuilder to String append .toString() method to sb
upvoted 1 times
...
Def8
2 years, 1 month ago
Selected Answer: A
It is very simple since equals method compare by value.
upvoted 1 times
...
ZINGOM
2 years, 3 months ago
A tostring convert a StringBuffer to a string
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