Question: Consider the following variable declarations: Integer n1 = 15; Integer n2 = 7; Integer n3 = 15; String s1 = computer; String s2 = soda;

Consider the following variable declarations:

Integer n1 = 15;

Integer n2 = 7;

Integer n3 = 15;

String s1 = "computer";

String s2 = "soda";

String s3 = "pencil";

Indicate whether the result of each of the following comparisons is positive, negative, or 0:

a. n1.compareTo(n2)

b. n3.compareTo(n1)

c. n2.compareTo(n1)

d. s1.compareTo(s2)

e. s3.compareTo(s1)

f. s2.compareTo(s2)

Step by Step Solution

3.36 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a n1compareTon2 0 b n3... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!