9
AssignmentMultiple Choice

New Data Types and the If Statement

Question 9 • ASC Programming, Games, Apps and Society

If you evaluated the statements for an if-else statement in a Java program, which format would produce ‘Answer is yes’ when the variable choice = 5?

Answer
A
if (choice<3) {System.out.println (‘Answer is yes’);} else {system.out.println (‘Answer is no’);
B
if (choice>3) {System.out.println (‘Answer is no’);} else {system.out.println (‘Answer is yes’);
C
if (choice>3) {System.out.println (‘Answer is yes’);} else {system.out.println (‘Answer is no’);}
D
if (choice=3) {System.out.println (‘Answer is yes’) else {system.out.println (‘Answer is no’);}
Previous
Next