Computer Applications
What is the value returned by function compareTo( ), if the invoking string is less than the string compared?
- zero
- value less than zero
- value greater than zero
- None of the above
Java String Handling
13 Likes
Answer
value less than zero
Reason — The compareTo() method compares two strings lexicographically, and returns a value based on the following logic:
if string1 > string2 the result will be a positive integer, i.e., result > 0
if string1 < string2 the result will be a negative integer, i.e., result < 0
if string1 = string2 the result will be 0, i.e., result = 0
Answered By
11 Likes
Related Questions
Which of the following statements is true?
- Binary search is less efficient than linear search.
- Binary search is more efficient than linear search.
- Binary search is as efficient as linear search.
- None of the above
Which element is num[9] of array num?
- 8th
- 9th
- 10th
- 11th
…………… class is used to convert a primitive data type to its corresponding object.
- String
- Wrapper
- System
- Math
This access specifier can be accessed only by the subclass in other package or any class within the same package.
- protected
- private
- public
- default