Answer is C, as although it looks like the OraString is overriding the equals method. But its actually just a method as the Objects equals method required Object as the parameter. Hence the second statement of if((s1 == "Moon") && (s2.equals("Moon"))) evaluates to false.
The answer is the letter C, even though I try the same content, strings are different if they are parsed as "==" or something like that because they are not primitive types. The correct way to compare the contents of String and different objects is equals and its variegated. Right in the first if of false (B) and in the second if of true (C), printing BC.
upvoted 1 times
...
Log in to ExamTopics
Sign in:
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.
7df49fb
3 months, 3 weeks agococobot
9 months, 2 weeks agocarloswork
1 year, 8 months agoiSnover
1 year, 9 months ago