b. myVar = 0;
2 You need to make a logical comparison where two values must return true in order for your code to execute the correct statement. Which logical operator enables you to achieve this?
a. AND
b. |
c. &
d. &&
d. &&
a. Boolean
b. if, else, else if
if(condition)
if(5a. Yes
a. foreach (int number in arrNumbers)
{
}
b. It causes the code to exit the switch statement.
c. for, foreach, while, do-while
9. How many times will this loop execute?
int value = 0;
do
{
Console.WriteLine (value);
} while value > 10;
a. 10 times
b. 1 time
c. 0 times
d. 9 timesb. 1 time
E1. Which of the following is NOT a comparison operator? a. != b = c. > d. <
b =
E2. Which of the following is the correct syntax for executing the following statements in an if statement?
Console.WriteLine(“In an if statement”);
Console.WriteLine();
a.
bool condition = true;
if(condition)
Console.WriteLine(“In an if statement”);
Console.WriteLine();
Console.WriteLine(“Outside the if statement”);
b.
bool condition = true;
if(condition)
{
Console.WriteLine(“In an if statement”);
Console.WriteLine();
}
Console.WriteLine(“Outside the if statement”);
c.
bool condition = true;
if(condition)
{
Console.WriteLine(“In an if statement”);
Console.WriteLine();
Console.WriteLine(“Outside the if statement”);
}
d.
bool condition = true;
if(condition)
{
Console.WriteLine(“In an if statement”);
}
Console.WriteLine();
Console.WriteLine(“Outside the if statement”);
b.
bool condition = true;
if(condition)
{
Console.WriteLine("In an if statement");
Console.WriteLine();
}
Console.WriteLine("Outside the if statement");E3. Which of the following looping structures must end with a semicolon?
a. for
b. foreach
c. do-while
d. while
c. do-while
E4. How do you handle multiple switch statements with one condition in a switch structure?
a. Remove the colon after the condition.
b. Enclose all the code statements you want executed together in curly braces.
c. Create separate switch statements.
d. Omit the break; statement.
structure?
d. Omit the break; statement.
structure?
E5. In a for statement, when does the incrementing of the counter take place?
a. On the last iteration only
b. At the end of each iteration
c. On the second and subsequent iterations only
d. At the end of the iteration and after the comparison
b. At the end of each iteration
E6. When can you assign a value to a variable?
a. During creation only
b. Only runtime in code
c. During declaration
d. Only at design time when writing the code
c. During declaration
E7. How can you tell when a statement has ended in C#?
a. Using the end of line character
b. Using the carriage return character
c. Using the colon
d. Using the semicolon
d. Using the semicolon
E8. What is a declaration statement used for in C#?
a. To declare a variable name
b. To declare a variable name and data type
c. To declare the beginning of program execution
d. To declare the beginning of a function
b. To declare a variable name and data type
E9. Which of these is not a valid C# statement?
a. ;
b. int myVar;
c. string string;
d. Console.WriteLine(“Hello world”);
c. string string;
E10. What is one common characteristic of complex statements?
a. They contain only complex statements.
b. They enclose statements in curly braces.
c. They enclose statements in parentheses.
d. They use tabs and other white space to tell the compiler where statements start and end.
b. They enclose statements in curly braces.
E11. In a complex if, else if structure, what keyword can be used to denote the final condition?
a. end if
b. endif
c. default
d. else
d. else