ISDS Chapter 4

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

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

(a || b) && (c || d)

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

Black and White

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

Red

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

White

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

White

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

Yellow

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

Yellow

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

a < b && c >= 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

if(itemNumber == 5 && (zone == 1 || zone == 3)) price = price + TAX;

Which of the following expressions assigns true to a Boolean variable named isIDValid when the idNumber is both greater than 1000 and less than or equal to 9999, or else 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

isIDValid = (idNumber > 1000 && idNumber <= 9999 || idNumber == 123456)

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

m == 0 ? d = 0 : d = 1;

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

none of these

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

one

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 run-time error occurs c. the program continues with the next executable statement d. the expression is incremented and the case values are tested again

the program continues with the next executable statement

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

x is a Boolean variable

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

Orange

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

end statement

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

if(g > h && g < k) Console.Write("Brown");

Which of the following C# expressions means, "If itemNumber is not 100, add TAX to price"? 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

if(itemNumber != 100) price = price + TAX;

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

if(itemNumber != 8 || itemNumber != 9) price = price + TAX;


Kaugnay na mga set ng pag-aaral

Life, Accident and Health Insurance

View Set

microeconomics midterm practice questions

View Set

Community Health Nursing Chapter 23 MC

View Set

Mishkin Chapter 4 - Understanding Interest Rates

View Set

Water Quality and General Types of Water Pollution.

View Set

Foundations of Kinesiology Ch. 1-7 {Midterm Study Guide}

View Set

How the Earth Was Made: Deepest Place on Earth Video Questions

View Set

International BLAW Part Three (chapters 8-15)

View Set