LearnFrenzy
Sign in Take a free test

Strings and StringBuilder · Java Strings MCQ · Question 8

The result of compareTo Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 8 Back to Exercise

What does "apple".compareTo("banana") return?

  • A A positive number
  • B A negative number Correct
  • C 0
  • D true
Correct Answer: Option B

"apple" comes before "banana": 'a' − 'b' = -1.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links