Programming Quiz 4

Ace your homework & exams now with Quizwiz!

In a switch statement, each of the case values must be unique (T or F)

True

The if-else statement will execute one group of statements if its boolean expression is true or another group if its boolean expression (T or F)

True

Java requires that the boolean expression being tested by an if statement be enclosed in...

a set of parenthesis

What will be displayed after the followung statements are excuted? int ans = 10; int x = 65; int y = 55; if (x>= y) int ans = x + y

120

What will be the value of x after the following statements are executed? int x = 75; int y = 60; if (x - y); x=x-y;

15

What will be displayed after the following statements are executed? int y = 10; if (y == 10) { int x = 30; x += y; System.out.println(x); }

40

What will be the value of ans after the following statements are executed? int x = 40; int y = 40; if (x = y); ans = x +10;

50

The boolean expression in an if statement must evaluate to...

true or false

The switch statement is a...

multiple alternative decision structure

In an if-else statement, if the boolean expression is false then...

the statements following the else is executed

Insert the missing parts to complete the following switch statement int day = 4; Switch( ____(day)____) { __(case)___ 1: System.out.println(saterday"); break; __(case)__ 2: System.out.println("sunday"); break;

Everything in parenthesis

If you prematurely terminate an if statement with a semicolon, the compiler will:

Not display an error message and assume you are placing a null statement there

A block of code is enclosed in a set of...

braces

The _________________ statement is used to create a decision structure which allows a program to have more than one path of execution.

if

Which of the following statements determines whether the variable temp is within the range of 0 through 100 (inclusive)?

if (temp>= 0 && temp <= 100)

Which of the following expressions will determine whether x is less than or equal to y?

x <= y


Related study sets

Ch. 11: Price: Determining Monetary and Nonmonetary Incentives and Disincentives

View Set

Computer Science Principles(Hexadecimal to Decimal)

View Set

Cellular Organization (2) - HW - Section 10 TR

View Set

Ch. 19 The heart and Cardiovascular function

View Set