Given the code fragment:
What is the result?
A. Match 1
B. Match 2
C. No Match
D. A NullPointerException is thrown at runtime.
Given the code fragment:
What is the result?
A. Match 1
B. Match 2
C. No Match
D. A NullPointerException is thrown at runtime.
correct is B
B is correct . The StringBuilder object and the string object are logically equal, but they are different types of objects and will never be equal.
The StringBuilder object is logically equal to the string object after it is converted into a string. They are all empty strings, so they are equal and output “Match 2”.