ACCP I10 SEMESTER PCS – PROGRAMMING IN C# MODULAR QUIZ FOR Session 02 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 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 Can you match the keywords in C# against their corresponding types of statements? A B C D E Selection Exception handling Iteration Jump Checked throw foreach return checked default 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 if only one of the bits is 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 5 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 B C D int valueOne = 10; int valueTwo = 20; int result; result = valueOne + valueTwo; valueTwo++; ++valueOne; result = valueOne++ + valueTwo—; Console.WriteLine (result); int valueOne = 10; int valueTwo = 20; int result; result = valueOne + valueTwo; valueTwo++; valueTwo = valueOne++; result = ++valueOne + —valueTwo; Console.WriteLine (result); int valueOne = 10; int valueTwo = 20; int result; result = valueOne + valueTwo; ++valueTwo; ++valueOne; result = ++valueOne + ++valueTwo; Console.WriteLine (result); int valueOne = 10; int valueTwo = 20; int result; result = valueOne + valueTwo; valueTwo++; ++valueOne; result = ++valueOne + valueTwo—; Console.WriteLine (result); 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 B C int input; Console.WriteLine("Enter a number : "); input = Convert.toInt32(Console.ReadLine()); Console.WriteLine(input); int input; Console.WriteLine("Enter a number : "); Input = Systern.ToInt(Console.ReadLine()); Console.WriteLine(input); int input; Console.WriteLine("Enter a number : "); input = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(input); int input; D Console.WriteLine("Enter a number : "); input = (toInt32)(Console.ReadLine()); Console.WriteLine(input); 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); 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 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]; D 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 Rectangular Array columns B Has improved performance Jagged Array C Have many values in a single row Single-dimensional Array D Has unequal number of columns Jagged Array E Have many rows and columns 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 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 B C D E specified index position Returns a 32-bit integer indicating the total number of elements in an array Returns an integer value indicating the number of dimensions in an array Returns number of elements in an array Creates an object of the Array class GetLength() Createlnstance() CopyTo() Length Rank Answers Question Answer c b, e, g A 5, B 1, C 2, D 3, E 4 b, c, d, e d c d b, c b, d, e 10 a 11 A 1, B 2, C 3, D 4, D 12 a, c 13 a 14 A 3, B 4, C 5, D 1, D