CTP 150 quiz 2

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

what are two method to determine if str1 is less than str2?

(str1.compareTo(str2) < 0)

double x = 45678.259 System.out.println("%.2f", x); what will be printed?

45,678.26

a boolean expression is one that is either

true or false

t/f: when testing for character values, the switch statement does not test for the case of the character

false

t/f: when two strings are compared using the compareTo method, the cases of the two strings are not considered

false

this is a boolean variable that signals when some condition exists in the program

flag

if chr is a character variable, which of the following if statements is correct

if (chr == 'a')

write a conditional expression to test wheter the variable grade contains an A B or C

if (grade == 'A' || grade == 'B' || grade == 'C")

int ans = 10; int x = 65; int y = 55; if (x >=y) int ans = x +y; what is value of ans?

no value, syntax error due to ans being redefined

t/f: a local variables scope always ends at the closing brace of the block of code in which it is declared

true

t/f: the if/else statement will execute one group of statements if its boolean expression is true or another group if its boolean expression is false

true

int bonus, sales = 1250; if (sales > 1000) bonus = 100; if (sales > 750) bonus = 50 if (sales > 500) bonus = 25; else bonus = 0; what is value of bonus?

25, each selection statement is executed since they are independent of the others

z = (a < 10)? 0: 7; rewrite the following using an if statement

if (a < 10) z = 0; else z = 7;

int y = 10; if (y == 10) { int x = 30; x += y; } System.out.print("x = " + x); what will be printed?

will not compile, x is unknown in the print statement due print statement being outside the if statement


Set pelajaran terkait

Principles of Supervision DSST Test Review

View Set

three types of cartilage tissue in body

View Set

Chapter 9: Care of Patients with Common Environmental Emergencies

View Set

Medieval Europe lesson 3 Kingdoms & Crusades

View Set

Carbon, Nitrogen, and Water Cycles

View Set