Question

Suppose you write the JAVA code to display "Cannot get a driver's license" if age is...

Suppose you write the JAVA code to display "Cannot get a driver's license" if age is less than 16
and "Can get a driver's license" if age is greater than or equal to 16.
Which of the following code is correct (HIGHLIGHT all that apply)?

I:
if (age < 16)
  System.out.println("Cannot get a driver's license");
if (age >= 16)
  System.out.println("Can get a driver's license");

II:
if (age < 16)
  System.out.println("Cannot get a driver's license");
else
  System.out.println("Can get a driver's license");

III:
if (age < 16)
  System.out.println("Cannot get a driver's license");
else if (age >= 16)
  System.out.println("Can get a driver's license");

IV:
if (age < 16)
  System.out.println("Cannot get a driver's license");
else if (age > 16)
  System.out.println("Can get a driver's license");
else if (age == 16)
  System.out.println("Can get a driver's license");

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I, II, III, IV
all of these are correct!
Add a comment
Know the answer?
Add Answer to:
Suppose you write the JAVA code to display "Cannot get a driver's license" if age is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java: The local Driver's License Office has asked you to write a program that grades the...

    Java: The local Driver's License Office has asked you to write a program that grades the written portion of the driver's   license exam. The exam has 20 multiple choice questions.   Here are the correct answers:    1. B  6. A  11.B  16. C    2. D  7. B  12.C  17. C    3. A   8. A  13.D  18. B    4. A  9. C  14.A  19. D    5. C  10. D  15.D  20. A    Your program should store the correct answers in an array. (Store each question's answer in an element of a String array.) The program...

  • Q1: Write a Java program that will display different messages depending on your age. Your program...

    Q1: Write a Java program that will display different messages depending on your age. Your program should ask the user for his/her name and their age in years and give one or more answers from the following ones below: if the age of the user is less than 16, the program should print on the screen “You are not allowed to drive at the moment”. if the age of the user is less than 18, the program should print on...

  • Write a Java Program to allow a user to guess a person’s age until they get...

    Write a Java Program to allow a user to guess a person’s age until they get it correct. After each guess, the user must be told whether their guess was correct, too high or too low. Once the user enters the correct age, the program must display how many guesses it took the user to guess the correct age.

  • PLEASE SOLVE THESE QUESTIONS. USE JAVA FOR CODING. Q.5.8 Write short Java code to display the...

    PLEASE SOLVE THESE QUESTIONS. USE JAVA FOR CODING. Q.5.8 Write short Java code to display the following screen (no need to do it practically using a compiler, just basic coding to display the screen): Sample screenshot Input х ? Enter (1) to display the vowel count. Enter (2) to display the non vowel count. Enter (0) to exit. OK Cancel Q.5.9 Write a short Java code to display the following screen (no need to do it practically using a compiler,...

  • Programming Language: Java 1. Write a class called Pair that stores a pair of numbers in...

    Programming Language: Java 1. Write a class called Pair that stores a pair of numbers in private fields. Include a two-arg constructor, mutators and accessors. Override the equals method so that a Pair (1,2) would be considered equal to Pair (2,1). Write an appropriate toString method and make the toString method non-overrideable. 2. Write an interface called Comparable that includes a method isGreater, isLesser, and isSame. These methods should each take a Pair object as a parameter. 3. Write an...

  • Java What keyword would you write in the --?-- place, to get this code to write...

    Java What keyword would you write in the --?-- place, to get this code to write the output 10210? int j = 20; for (int i = 0; i < 5; i++) { j = j/2; if (j == 5) --?--; System.out.print(j); }

  • Java Branches code not working please HELP!! I am trying to build this class that will...

    Java Branches code not working please HELP!! I am trying to build this class that will ask for an ingredient, and the number of cups of the ingredient. It should then branch into an if/else branch off to verify that the number entered is valid and that it is within range. Once that branch completes it should then continue on to ask for the calories per cup, and then calculate total calories. Once I get it to enter the branch...

  • Java Programming Question. I am writing a code to calculate the roots of the quadratic equation...

    Java Programming Question. I am writing a code to calculate the roots of the quadratic equation based on the values of the coefficients A, B, and C. I am supposed to enter 5 values for each coefficient, and the output should be five different answers (see example) using a for loop and if else statements. However, when I run my code, I am only able to enter one value for each coefficient and the output is one answer repeated five...

  • please who can help with this question in Java 1.  Write a class called Pair that...

    please who can help with this question in Java 1.  Write a class called Pair that stores a pair of numbers in private fields. Include a two-arg constructor, mutators and accessors. Override the equals method so that a Pair (1,2) would be considered equal to Pair (2,1). Write an appropriate toString method and make the toString method non-overrideable. 2.  Write an interface called Comparable that includes a method isGreater, isLesser, and isSame. These methods should each take a Pair object...

  • Write the code in java programming language To get some practice with recursion. You can do...

    Write the code in java programming language To get some practice with recursion. You can do all this in one driver program. Write a recursive method to compute the result of the Fibonacci sequence: Fibonacci(N) = Fibonacci(N -1) + Fibonacci(N-2) N == 0 is 0 N == 1 is 1 Testing: Display the result for Fibonacci(N) and the number of function calls for N = 2, 5 and 10.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT