State the data type and values of a and b after the following segment is executed:

String s1 = "Computer", s2 = "Applications"
a = (s1.compareTo(s2));
b = (s1.equals(s2));

Views 12

Answer:

Data type of a is int and value is 2. Data type of b is boolean and value is false.

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.