1.

What is the value returned by function compareTo() if the invoking string is less than the string compared?(a) zero(b) value less than zero(c) value greater than zero(d) none of the mentionedI have been asked this question during an interview for a job.My enquiry is from String Comparison topic in chapter String Handling of Java

Answer» CORRECT answer is (b) VALUE less than zero

Explanation: compareTo() function returns zero when both the strings are equal, it returns a value less than zero if the INVOKING string is less than the other string being COMPARED and value GREATER than zero when invoking string is greater than the string compared to.


Discussion

No Comment Found

Related InterviewSolutions