Chapter 4

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

If the following code segment compiles correctly, what do you know about the variable x? if(x) WriteLine("OK"); a. x is an integer variable b. x is a Boolean variable c. x is greater than 0 d. none of these

b

Falling through a switch case is most often prevented by using the _________ statement. a. break b. default c. case d. end

a

How many case labels would a switch statement require to be equivalent to the following if statement? if(v == 1) WriteLine("one"); else WriteLine("two"); a. zero b. one c. two d. impossible to tell

b

Which of the following C# expressions means, "If itemNumber is 5 and zone is 1 or 3, add TAX to price"? a. if(itemNumber == 5 && zone == 1 || zone == 3) price = price + TAX; b. if(itemNumber == 5 && (zone == 1 || zone == 3)) price = price + TAX; c. if(itemNumber == 5 && (zone == 1 || 3)) price = price + TAX; d. two of these

b

Which of the following is equivalent to the following statement: if(m == 0) d = 0; else d = 1; a. d = (m == 0) : d = 0, d = 1; b. m ? (d = 0); (d = 1); c. m == 0; d = 0; d = 1? d. d = (m == 0) ? 0 : 1;

d

What is the output of the following code segment? int e = 5, f = 10; if(e < f || f < 0) Write("Red"); else Write("Orange"); a. Red b. Orange c. RedOrange d. nothing

a

What is the output of the following code segment? int a = 3, b = 4; if(a == b) Write("Black"); WriteLine("White"); a. Black b. White c. BlackWhite d. nothing

b

What is the output of the following code segment? int c = 6, d = 12; if(c < d) if(c > 8) Write("Green"); else Write("Yellow"); else Write("Blue"); a. Green b. Yellow c. Blue d. nothing

b

Which of the following C# expressions is equivalent to a < b && b < c? a. c > b > a b. a < b && c >= b c. !(b <= a) && b < c d. two of these

c

Which of the following expressions is equivalent to the following code segment? if(g > h) if(g < k) Write("Brown"); a. if(g > h && g < k) Write("Brown"); b. if(g > h && < k) Write("Brown"); c. if(g > h || g < k) Write("Brown"); d. two of these

a

What is the output of the following code segment? int a = 3, b = 4; if(a > b) Write("Black"); else WriteLine("White"); a. Black b. White c. BlackWhite d. nothing

b

What is the output of the following code segment? int e = 5, f = 10; if(e < f && f < 0) Write("Red"); else Write("Orange"); a. Red b. Orange c. RedOrange d. nothing

b

Which of the following C# expressions means, "If itemNumber is not 8 or 9, add TAX to price"? a. if(itemNumber != 8 || itemNumber != 9) price = price + TAX; b. if(itemNumber != 8 && itemNumber != 9) price = price + TAX; c. if(itemNumber != 8 && != 9) price = price + TAX; d. two of these

b

If the test expression in a switch does not match any of the case values, and there is no default value, then _________. a. a compiler error occurs b. a runtime error occurs c. the program continues with the next executable statement d. the expression is incremented and the case values are tested again

c

What is the output of the following code segment? int a = 3, b = 4; if(a < b) { Write("Black"); WriteLine("White"); } a. Black b. White c. BlackWhite d. nothing

c

What is the output of the following code segment? int c = 6, d = 12; if(c > d); Write("Green"); WriteLine("Yellow"); a. Green b. Yellow c. GreenYellow d. nothing

c

Which of the following expressions is equivalent to a || b && c || d? a. a && b || c && d b. (a || b) && (c || d) c. a || (b && c) || d d. two of these

c

Which of the following C# expressions means, "If itemNumber is 1 or 2 and quantity is 12 or more, add TAX to price"? a. if(itemNumber = 1 || itemNumber = 2 && quantity >= 12) price = price + TAX; b. if(itemNumber == 1 || itemNumber == 2 || quantity >= 12) price = price + TAX; c. if(itemNumber == 1 && itemNumber == 2 && quantity >= 12) price = price + TAX; d. none of these

d

Which of the following C# expressions results in TAX being added to price if the integer itemNumber is not 100? a. if(itemNumber != 100) price = price + TAX; b. if(!(itemNumber == 100)) price = price + TAX; c. if((itemNumber <100) || (itemNumber > 100)) price = price + TAX; d. all of these

d

Which of the following expressions assigns true to a Boolean variable named isIDValid when idNumber is both greater than 1000 and less than or equal to 9999, or else is equal to 123456? a. isIDValid = (idNumber > 1000 && idNumber <= 9999 && idNumber == 123456) b. isIDValid = (idNumber > 1000 && idNumber <= 9999 || idNumber == 123456) c. isIDValid = ((idNumber > 1000 && idNumber <= 9999) || idNumber == 123456) d. two of these

d


Set pelajaran terkait

Carter📝📚 - Margaret Atwood, Running with the Tigers🐯

View Set

RN COMMUNITY HEALTH NURSING—CHAPTER 7: Continuity of Care

View Set

FINAL REVIEW Chapter 1 - MONGO DB

View Set

Chapter 18 Building Careers and Writing Résumés

View Set

Health Assessment in Nursing, Chapter 3

View Set