Computer Applications
The method compareTo() returns …………… when two strings are equal and in lowercase :
- true
- 0
- 1
- false
Java String Handling
ICSE Sp 2024
35 Likes
Answer
0
Reason — compareTo() method compares two strings lexicographically and returns the difference between the ASCII values of the first differing characters in the strings. Here, the strings are equal so the difference is 0.
Answered By
18 Likes
Related Questions
Constructor overloading follows which principle of Object Oriented programming?
- Inheritance
- Polymorphism
- Abstraction
- Encapsulation
Which of the following is a valid Integer constant:
i. 4
ii. 4.0
iii. 4.3f
iv. "four"- Only i
- i and iii
- ii and iv
- i and ii
Assertion (A): In Java, statements written in lower case letter or upper case letter are treated as the same.
Reason (R): Java is a case sensitive language.
- Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of Assertion (A)
- Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of Assertion (A)
- Assertion (A) is true and Reason (R) is false
- Assertion (A) is false and Reason (R) is true
Read the following text, and choose the correct answer:
A class encapsulate Data Members that contains the information necessary to represent the class and Member methods that perform operations on the data member.
What does a class encapsulate?
- Information and operation
- Data members and Member methods
- Data members and information
- Member methods and operation