Question: / / SELF - CHECK PROBLEMS: / / Note: you may need to put some of your answers inside comments / / 2 1 .

// SELF-CHECK PROBLEMS:
// Note: you may need to put some of your answers inside comments
//21. 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)
//22.Use the compareTo method to write code that reads two names from the
// console and prints the one that comes first in alphabetical order. For
// example, the programs output might look like the following:
// Type a name: Tyler Durden
// Type a name: Marla Singer
// Marla Singer goes before Tyler Durden
//23.Write code to read a line of input from the user and print the words of
// that line in sorted order, without removing duplicates. For example, the
// program output might look like the following:
// Type a message to sort: to be or not to be that is the question
// Your message sorted: be be is not or question that the to to
// EXERCISES:
// None
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!