JAVA PROGRAMMING-LMS INTEG.MINDTAP
JAVA PROGRAMMING-LMS INTEG.MINDTAP
8th Edition
ISBN: 9781337091503
Author: FARRELL
Publisher: Cengage Learning
bartleby

Concept explainers

Expert Solution & Answer
Book Icon
Chapter 7, Problem 9RQ

<PROGRAM-DESCRIPTION-ANSWER>

The expression name1.compareTo(name2) contains the value “-1”.

Hence, the correct option is “C”.

</PROGRAM-DESCRIPTION-ANSWER>

Explanation of Solution

Given:

String name1 = new String ("Jordan");

String name2 = new String ("Jore");

To find:

name1.compareTo (name2)

Explanation:

  • Here, “name1” is the string variable and assign with a string value “Jordan”.
  • The “name2” is the string variable and assign with a string value “Jore”...

Blurred answer
Students have asked these similar questions
IntelliJ 1. Create a String constant ‘SPACE’, which holds a space ( “ “ ). final ​String SPACE = ​" "​; /*‘final’ keyword creates a constant in Java. Once a ‘final’ variable is initialized, it values cannot be changed*/2. Get the name of your ( or a fictional ) pet and save it to a String variable. 3. Get the age of your (or a fictional ) pet and save it to an int variable.4. Print out the name and age of your pet, use your constant in the println wherever space character is needed.   Sample output: Enter name: Yoyo Enter age: 3 My pet's name:Yoyo My pet's age: 3
name: string - ownerName: String Cat numberOfTeeth int lengthofTail : int + Cat (name: String, ownerName: String, numberOfTeeth: int, lengthofTail:int) i. ii. + Pet (name:String, ownerName: String) + getName(): String + getownerName (): String + getNumberOfTeeth (): int + getLengthofTail(): int Pet iii. Budgie colourOfFeathers: String + Budgie (name: String, 1. Convert the UML class diagram above into a java code with the following conditions The methods in the Pet class are abstract. ownerName: String, colourofFeathers:String) + getColourOfFeathers (): String Create a class called test. The main() method in the test class should create three Cat objects and two Budgie objects. The main() method should also create indirectly an object of the Pet class. Demonstrate polymorphism in your test class. 2. Write a Java Code for a simple GUI program that creates a frame and changes the background to green. Examiner's Name: George Kodjo Anni
Write a program in the StringManipulator class that creates a String variable that references a String object holding the name of your favorite city. The program should display the following: • The number of characters in the city name• The name of the city in all uppercase letters • The name of the city in all lowercase letters • The first character in the name of the city
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage