The String method compareTo() returns
A. true
B. false
C. an int value
D. 1
E. -1
Answer: Option C
A. true
B. false
C. an int value
D. 1
E. -1
Answer: Option C
In Java, which class is used to represent a sequence of characters as a string?
A. String
B. StringBuilder
C. StringSequence
D. StringArray
What is the correct way to create a new empty String object in Java?
A. String emptyString = "";
B. String emptyString = new String();
C. String emptyString = " ";
D. String emptyString = null;
E. Both A and B
Which of the following methods is used to compare two strings for equality in Java?
A. equals()
B. compareTo()
C. equalsIgnoreCase()
D. compare()
compareTo() method compares first argument with second argument and returns positive number , if first argument is bigger than the second number .
returns negitive number if first argument is less than second argument and zero if both are equal