The block of code following the if statement is skipped if the condition in the if statement returns false?. The elements of an array are typically not of the same data type.. Which of t
Trang 1ACCP I10 SEMESTER 2 PCS – PROGRAMMING IN C#
MODULAR QUIZ
FOR Session 02
1. Which of these statements about expressions and statements are true and which
statements are false?
A. Statements end with a comma
B. Functions refer to related statements in a program
C. Expressions are part of statements
D. Jump statements help in executing another block of code repeatedly
E. Expressions might not always return values
2. Which of these following options are types of statements?
A. Block Statements
B. Selection Statements
C. Decision-making Statements
D. Logical Statements
E. Exception Handling Statements
F. Loop Statements
G. Iteration Statements
H. Error Handling Statements
3. Can you match the keywords in C# against their corresponding types of statements?
A. Selection
B. Exception handling
C. Iteration
D. Jump
E. Checked
1. throw
2. foreach
3. return
4. checked
5. default
4. Which of the following statements on arithmetic and logical operators and operator precedence are true and which statements are false?
A. The conditional operator works with two operands
B. The increment operator works with a single operand
C. The bitwise exclusive OR operator compares bits and returns 1 if only one of the bits
is 1
D. The conditional && operator does not check the second expression if the first
expression is false
E. The compound assignment operators execute from right to left
Trang 25. You are trying to manipulate the values in the variables value One and value Two using the increment and decrement operators such that the final value is 33 and is stored in the result variable Which of the following codes will help you to achieve this?
A int valueOne = 10;
int valueTwo = 20;
int result;
result = valueOne + valueTwo;
valueTwo++;
++valueOne;
result = valueOne++ + valueTwo—;
Console.WriteLine (result);
B int valueOne = 10;
int valueTwo = 20;
int result;
result = valueOne + valueTwo;
valueTwo++;
valueTwo = valueOne++;
result = ++valueOne + —valueTwo;
Console.WriteLine (result);
C int valueOne = 10;
int valueTwo = 20;
int result;
result = valueOne + valueTwo;
++valueTwo;
++valueOne;
result = ++valueOne + ++valueTwo;
Console.WriteLine (result);
D. int valueOne = 10;
int valueTwo = 20;
int result;
result = valueOne + valueTwo;
valueTwo++;
++valueOne;
result = ++valueOne + valueTwo—;
Console.WriteLine (result);
6. You are trying to convert and display the input from the console window to a 32-bit signed integer Which of the following codes will help you to achieve this?
A. int input;
Console.WriteLine("Enter a number : ");
input = Convert.toInt32(Console.ReadLine());
Console.WriteLine(input);
B. int input;
Console.WriteLine("Enter a number : ");
Input = Systern.ToInt(Console.ReadLine());
Console.WriteLine(input);
C. int input;
Console.WriteLine("Enter a number : ");
Trang 3input = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(input);
D. int input;
Console.WriteLine("Enter a number : ");
input = (toInt32)(Console.ReadLine());
Console.WriteLine(input);
7. You are trying to convert and display a reference type to the float type Which of the following codes will help you to achieve this?
A object obj = 100.50;
float num = float (obj);
Console.WriteLine (num);
B object obj = 100.50F;
Float num = (Float) obj;
Console.WriteLine (num);
C object obj = 100.50;
float num = obj (float);
Console.WriteLine (num);
D object obj = 100.50F;
float num = (float)obj;
Console.WriteLine (num);
8. Which of these statements about the selection constructs of C# are true and which
statements are false?
A. A selection construct executes a block of code for the number of times specified in the condition
B. The block of code following the if statement is skipped if the condition in the if statement returns false
C. The if .else if construct checks multiple conditions and executes an appropriate block
of code for each condition
D. The inner if statements of the nested if construct control the execution of the outer if statement
E. The switch statement can contain an expression of type string
9. Which of these statements about arrays are true and which statements are false?
A. The elements of an array are typically not of the same data type
B. The first element of an array is always indexed zero
C. The last element of an array is always indexed at (n - 2) position
D. An array is used to achieve contiguous memory collection of values of a particular data type
E. The size of an array is declared using an int variable
10. You are trying to create an array of type string that will store seven values Which of the following codes helps you to achieve this?
A. public string[] cities = new string[7];
B. public string[7] cities = new[] string;
C. public string cities[] = new string[7];
Trang 4D. public string cities[7] = new string{};
11. Can you match the terms used in arrays against their corresponding descriptions?
A. Has equal number of rows and
columns
1. Rectangular Array
B. Has improved performance 2. Jagged Array
C. Have many values in a single row 3. Single-dimensional Array
D. Has unequal number of columns 4. Jagged Array
E. Have many rows and columns 5. Multi-dimensional Array
12. Which of these statements about types of arrays are true and which statements are false?
A. The foreach loop is used to prevent any changes to the elements specified in the collection
B. A single-dimensional array is referred to as an n-dimensional array where n is the number of elements
C. A jagged array is a set of multiple arrays
D. The new keyword is used to declare a single-dimensional array
E. The single-dimensional array is a type of array that stores the first element in the index position 1
13. Which of these statements about the Array class are true and which statements are false?
A. The Array class exists in the System namespace
B. The Array class contains the Createlnstance () method that allows you to change the elements in an array
C. The Array class declares methods to create and manipulate only multi-dimensional arrays
D. The Array class defines the Copy() method to create a copy of an array
E. The Array class contains the Dimensions property that determines the dimensions of
an array
14. Can you match the properties and methods of the Array class against their corresponding descriptions?
A. Places elements in another array from the
specified index position
1. GetLength()
B. Returns a 32-bit integer indicating the total
number of elements in an array 2.
Createlnstance()
C. Returns an integer value indicating the
number of dimensions in an array
3. CopyTo()
D. Returns number of elements in an array 4. Length
E. Creates an object of the Array class 5. Rank
Trang 53 A 5, B 1, C 2, D 3, E 4
4 b, c, d, e
11 A 1, B 2, C 3, D 4, D 5
14 A 3, B 4, C 5, D 1, D 2