ch 5 classes.quiz

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

_____operators allow you to test variables to see if one is greater or less than another variable or value.

Relational

if (examScore is less than 50) display message "Do better on next exam" The result of the expression above is ____. a.true or false b.true c.numeric d.100

true or false

f (a > 10) if (b > 10) if (c > 10) result = 1; else if (b > 100) result = 2; else result = 3; else result = 4; else result = 5; Using the above code segment, what is stored in result when a, b and c are equal to 200? a.1 b.2 c.3 d.4

1

if (amount > 1000) result = 1; else if (amount > 500) result = 2; else if (amount > 100) result = 3; else result = 4; Using the above code segment, what is stored in result when amount is equal to 876? a. 1 b. 2 c. 3 d. 4

2

Which of the following statements is NOT true regarding switch statements? a.The expression is sometimes called the selector. b.Default is only executed when there is no match. c.Default is required. d.A variable cannot be used as the case label.

Default is required.

switch (phoneDigit) { case 1: num = 1; break; case 2: num = 2; break; case 3: num = 3; break; case 4: num = 4; break; default: num = 0; break; } Looking at the example above, what happens if the break is omitted? a.a syntax error is generated b.num is always assigned 0 c.num is never assigned a value d.num is assigned 1

a syntax error is generated

Conditional expressions produce a / an ____result.

boolean

The switch statement case value can evaluate to all of the following EXCEPT ____. a.double b.int c.string d.char

double

if (examScore > 89) grade = 'A'; Console.WriteLine("Excellent"); Using the code snippet above, when does Excellent get displayed? a.whenever the score is greater than 89 b.when the score is less than or equal to 89 c.never, a syntax error is generated d.every time the program is run

every time the program is run

if (examScore > 89); grade = 'A'; Using the code snippet above, when does grade get assigned a value of 'A'? a.whenever the score is greater than 89 b.when the score is less than or equal to 89 c.never, a syntax error is generated d.every time the program is run

every time the program is run

Boolean variables store 0 to represent off or false and 1 to represent on or true. Select one: True False

false

In C#, both the break and default are optional entries found with a switch statement. Select one: True False

false

Iteration, also called selection is used for decision making and allows your program statements to deviate from the sequential path and perform different statements based on the value of an expression. Select one: True False

false

Two equal symbol characters == are used as the assignment operator. Select one: True False

false

A company issues $5,000.00 bonuses at the end of the year to all employees who earn less than $100,000. Salary and bonus are both defined as double data types. Which of the following selection statements would assign the correct amount to bonus? a. if (salary < $100,000) bonus == $5000; b. if (salary < 100000) bonus = 5000; CorrectCorrect c. if (salary <= 100000) bonus = 5000; d. if (salary < 100000); bonus = $5000;

if (salary < 100000) bonus = 5000;

By properly_____ the else clauses with their corresponding if clauses, you encounter fewer logic errors that necessitate debugging.

lining up

if (aValue < largest ) result = aValue; else result = largest; What happens when aValue is equal to largest in the program segment above? a. result is assigned aValue b. result is assigned largest c. nothing, neither assignment statement is executed d. an error is reported

result is assigned largest

When you compare characters stored in char memory locations using relational operators, ____. a.they are compared lexicographically b.you receive an error message c.they are always considered equal d.you get inconsistent results

they are compared lexicographically

After completing the program, you should compare the results produced with the desk checked calculated results. Select one: True False

true

Class diagrams list the data field members in the center rectangle and the methods or behaviors in the bottom rectangle. Select one: True False

true

Equality comparisons with floating-point and decimal types often produce unpredictable results. Select one: True False

true

In C#, the && and || operators are also called the short-circuiting logical operators. Select one: True False

true

The expression, (5 > 57 % 8), evaluates to ___ a.true b.false c.1 d.5 > 1

true

The switch statement is considered a multiple selection structure and it also goes by the name case statement. Select one: True False

true

The ternary operator ( ? : ) provides another way to express a simple if...else selection statement. Select one: True False

true


Kaugnay na mga set ng pag-aaral

PN MENTAL HEALTH ONLINE PRACTICE 2017 A

View Set

Property-Insurance Terms & Related Concepts

View Set

Environmental Science Ch. 10-14 (edited)

View Set

Environmental 2.7-2.8 Study Guide

View Set

Ch 18. Cardiovascular System: Blood

View Set

Prep U | Oxygenation and Perfusion

View Set

PSU Econ304 section3 Lesson3 production and the classical labor market model Quiz

View Set