Computer Applications
Which of the following String methods returns a negative value?
- length()
- equals()
- compareTo()
- charAt()
Answer
compareTo()
Reason — The compareTo() method compares two strings lexicographically and returns an integer value which can be positive, zero, or negative depending on the comparison. The methods length() returns the length (non-negative), equals() returns a boolean, and charAt() returns a character, so none of them can return a negative value.
Related Questions
To extract the word NOW from the word "ACKNOWLEDGEMENT", the Java statement
"ACKNOWLEDGEMENT".substring(3, ...............)is used.Choose the correct number to fill in the blank.
- 6
- 7
- 5
- 8
The output of the below statement is:
String a[] = {"Atasi", "Aditi", "Anant", "Amit", "Ahana"}; System.out.println(a[1].charAt(1) + "*" + a[2].charAt(2));- da
- d*a
- ti
- t*i
An array with 3 elements is arranged in a ascending order as follows:

Name the technique used:
- Bubble sort
- Linear Search
- Selection sort
- Binary Search
The sales made by 5 salesmen selling 5 products is stored in a two-dimensional array of integer data type. How many bytes does the array occupy?
- 25
- 200
- 50
- 100