Вы находитесь на странице: 1из 17

[1]

Which of the following statements are correct? I. Variables of reference types referred to as objects and store references to the actual data. II. String is a built-in value type.

a) b) c) d)

Only I is correct. Only II is correct. Both I and II are correct. Both I and II are incorrect.

[2]

Which of the following statements are correct?

I. II. III.

When a value type is boxed, an entirely new object must be allocated and constructed. The value type is stored on the garbage collected heap. Unboxing a value type packages it inside an instance of the Object reference type.

Choice a Only I and II are correct. Choice b Only I and III are correct. Choice c Only II and III are incorrect. Choice d I, II and III are correct.

[3]

Which of the following statements are correct?

I.

It is possible for a value type to contain the null value.

II. Each value type has an implicit default constructor that initializes the default value of that type. Choice a Only I is correct. Choice b

Only II is correct. Choice c Both I and II are correct. Choice d Both I and II are incorrect.

[4]

All value types are derived implicitly from which of the following class?

Choice a System.DataType.ValueType Choice b System.ValueType Choice c System.DataValueType Choice d System.ValueType.DataType

[5]

Which of the following statements are correct?

I.

Local variables in C# must be initialized before being used.

II. Using the new operator calls the default constructor of the specific type and assigns the default value to the variable. Choice a Only I is correct. Choice b Only II is correct. Choice c Both I and II are correct. Choice d Both I and II are incorrect.

[6]

Which of the following statements are correct?

I. II.

Nullable types represent value-type variables that can be assigned the value of null. We can create a nullable type based on a reference type.

Choice a Only I is correct. Choice b Only II is correct. Choice c Both I and II are correct. Choice d Both I and II are incorrect.

[7]

Which of the following statements are correct?

I. Boxing is an explicit conversion from an interface type to a value type that implements the interface. II. An unboxing operation consists of checking the object instance to make sure it is a boxed value of the given value type. III. An unboxing operation consists of copying the value from the instance into the value-type variable. Choice a Only I and II are correct. Choice b Only I and III are correct. Choice c Only II and III are correct. Choice d I, II and III are correct. [8] Which of the following statements are correct?

I. II.

We can assign values of any type to variables of type object. When a variable of a value type is converted to object, it is said to be unboxed.

Choice a Only I is correct. Choice b Only II is correct. Choice c Both I and II are correct. Choice d Both I and II are incorrect.

[9]

Which of the following statements are correct?

I. II.

When a variable of type object is converted to a value type, it is said to be boxed. Boolean variable cannot have a value of null.

Choice a Only I is correct. Choice b Only II is correct. Choice c Both I and II are correct. Choice d Both I and II are incorrect.

[10]

Which of the following statements are correct?

I. II.

Assigning one value type variable to another copies the contained value. It is possible to derive a new type from a value type.

Choice a Only I is correct. Choice b Only II is correct. Choice c Both I and II are correct. Choice d Both I and II are incorrect. [11] Which of the following statements are correct?

I. Variables of the value types store references to the actual data while those of the reference types store data. II. It is possible to convert a value type to a reference type and back again to value types.

Choice a Only I is correct. Choice b Only II is correct. Choice c Both I and II are correct. Choice d Both I and II are incorrect. [12] Which of the following statements are correct?

I. II.

Reference types are either stack-allocated or allocated inline in a structure. Value types are heap-allocated.

Choice a

Only I is correct. Choice b Only II is correct.

Choice c Both I and II are correct. Choice d Both I and II are incorrect.

[13]

Which of the following is NOT an Integer?

Choice a Char Choice b Byte Choice c Short Choice d Integer [14] Which of the following statements are correct?

I. The foreach statement repeats a group of embedded statements for each element in an array or an object collection. II. The foreach statement is used to iterate through the collection to get the desired information and should be used to change the contents of the collection to avoid unpredictable side effects. Choice a Only I is correct. Choice b

Only II is correct. Choice c Both I and II are correct. Choice d Both I and II are incorrect.

[15]

Which of the following statements are correct?

I. If we wish to execute more than one statement, multiple statements can be conditionally executed by including them into blocks using { }. II. The statements to be executed upon testing the condition can be of any kind, including another if statement nested into the original if statement. Choice a Only I is correct. Choice b Only II is correct. Choice c Both I and II are correct. Choice d Both I and II are incorrect. [16] Which of the following statements are correct?

I. A jump statement such as a break is required after each case block excluding the last block if it is a default statement. II. C# always supports an implicit fall through from one case label to another.

Choice a Only I is correct. Choice b Only II is correct.

Choice c Both I and II are correct. Choice d Both I and II are incorrect. [17] Which of the following statements are correct?

I. The if statement selects a statement for execution based on the value of a Boolean expression. II. After executing the if statement, control is transferred to the next statement.

Choice a Only I is correct. Choice b Only II is correct. Choice c Both I and II are correct. Choice d Both I and II are incorrect.

[18]

Which of the following statements are correct?

I. In nested if statements the else clause belongs to the last if that does not have a corresponding else. II. It is not possible to extend the if statement to handle multiple conditions using the else-if arrangement. Choice a Only I is correct. Choice b Only II is correct. Choice c

Both I and II are correct. Choice d Both I and II are incorrect.

[19] Which of the following statements are correct?

I. Because the test of conditional expression takes place before the execution of the loop, therefore, a for statement executes zero or more times. II. are All of the expressions of the for statement not optional.

Choice a Only I is correct. Choice b Only II is correct. Choice c Both I and II are correct. Choice d Both I and II are incorrect.

[20]

Which of the following statements are correct?

I. The switch statement is a control statement that handles multiple selections and enumerations by passing control to one of the case statements within its body. II. The switch statement can include any number of case instances with two case statements having the same value. Choice a Only I is correct. Choice b Only II is correct. Choice c

Both I and II are correct. Choice d Both I and II are incorrect. [21] Which of the following statements are correct?

I. A common use of continue is to transfer control to a specific switch-case label or the default label in a switch statement. II. The do statement executes a statement or a block of statements enclosed in {} repeatedly until a specified expression evaluates to false.

Choice a Only I is correct. Choice b Only II is correct. Choice c Both I and II are correct. Choice d Both I and II are incorrect.

[22] Which of the following can be used to terminate a while loop and transfer control outside the loop?

I. II. III. IV.

break statement goto statement return statement throw statement

Choice a

Only I Choice b Only I and II Choice c Only II Choice d I, II, III and IV

[23] Which of the following statement is correct about the code snippet given below? using System ; namespace ConsoleApplication1 { class Program { static void Main ( string[ ] args ) { decimal d = 9.1m ; int y = 3 ; Console.WriteLine ( d + y ) ; } } } Choice a The code reports an error. Choice b The code causes System.TypeMismatchException. Choice c The code causes System.InvalidCastException. Choice d The code gives an output as 12.1. [24] Which of the following statements are correct? I. We can cast the integral character codes. II. A char can be implicitly converted to only int data type. III. There are no implicit conversions from other types to the char type. Choice a Only I and II are correct. Choice b Only I and III are correct. Choice c Only II and III are correct. Choice d

I, II and III are correct. [25] Which of the following statement is correct about the code snippet given below? using System ; namespace ConsoleApplication1 { class Program { static void Main ( string[ ] args ) { char c = 0' ; bool b = c ; Console.WriteLine ( b ) ; } } } Choice a The code reports an error. Choice b The code causes System.InvalidCastException. Choice c The code gives output as False. Choice d The code gives output as True. [26] Which of the following statement you will add to the code snippet given below to store the summation of x and y in z? using System ; namespace ConsoleApplication1 { class Program { static void Main ( string[ ] args ) { byte x = 10, y = 20, z ; // Add statement here } } } Choice a z=x+y; Choice b z = ( byte ( x + y ) ) ; Choice c z = ( byte ) ( x + y ) ; Choice d ( byte ) z = x + y ;

[27] Which of the following statement is correct about the code snippet given below? using System ; namespace ConsoleApplication1 { class Program { static void Main ( string[ ] args ) { decimal x = 0.999m ; decimal y = 99999m ; Console.WriteLine ( ( Convert.ToString ( x ) ) + " " + ( Convert.ToString ( y ) ) ) ; } } } Choice a The code reports an error as type decimal cannot be converted to type string. Choice b The code causes System.InvalidCastException. Choice c

The code gives an output as 1 99999. Choice d The code gives an output as 0.999 99999.

[28] Which of the following statements are correct? I. Attempting to unbox null or a reference to an incompatible value type will result in an InvalidCastException. II. There is no conversion between the bool type and other types. III. Constants of the char type can be written as character literals, hexadecimal escape sequence or Unicode representation. Choice a Only I and II are correct. Choice b Only I and III are correct. Choice c Only II and III are correct. Choice d I, II and III are correct. [29] Which of the following statement is correct about the code snippet given below?

using System ; namespace ConsoleApplication1 { class Program { static void Main ( string[ ] args ) { bool? flag = null ; Console.WriteLine ( Convert.ToBoolean ( flag ) ) ; } } } Choice a

The code reports an error as value null cannot be converted to type string. Choice b The code causes System.InvalidOperationException. Choice c The code gets compiled successfully but does not give any output. Choice d The code gives an output as False. [30] Which of the following statement is correct about the code snippet given below?

using System ; namespace ConsoleApplication1 { class Program { static void Main ( string[ ] args ) { bool? letter = Convert.ToBoolean ( 5 ) ; Console.WriteLine ( letter ) ; } } } Choice a The code reports an error as type int cannot be stored as nullable type. Choice b The code causes System.InvalidOperationException. Choice c The code causes System.InvalidCastException. Choice d The code gives an output as True.

31. Which of the following statements are correct?


I. Branching is performed using jump statements which cause an immediate transfer of the program control. II. The goto statement passes control to the next iteration of the enclosing iteration statement in which it appears. Only I is correct. Only II is correct. Both I and II are correct. Both I and II are incorrect.

32. I.

The body loop of the do statement is executed at least once regardless of the value of the

expression. II. The for loop is handy for iterating over arrays and for sequential processing. Only I is correct. Only II is correct. Both I and II are correct. Both I and II are incorrect.

33. Which of the following statement is correct about the code snippet given below? using
System ; namespace ConsoleApplication1 { class Program { static void Main ( string[ ] args ) { byte mybyte = 256 ; Console.WriteLine ( mybyte ) ; } } } The code reports an error. The code causes System.InvalidCastException The code causes System.OutOfRangeException. The code gives an output as 256.

34. using System ; namespace ConsoleApplication1 { class Program { static void Main ( string[ ] args ) { int i = 123 ; object o = i ; short j = ( short ) o ; Console.WriteLine ( j ) ;

} } } The code reports an error. The code causes System.InvalidCastException. The code gets compiled successfully but does not give any output. The code gives an output as 123.

35.

Which of the following statements are correct?

I. If the interger exceeds the range of byte, a compilation error will occur.

II.Byte cannot be implicitly converted to float. III.We cannot implicitly convert non-literal types of larger storage to byte.
Only I and II are correct. Only I and III are correct. Only II and III are correct. Only I II III are correct.

36. using System ; namespace ConsoleApplication1 { class Program { static void Main ( string[ ] args ) { int i = 123 ; object o = i ; I=456; System.Console.WriteLine(Conveert.ToString(i)+Convert.ToString(o));

} } } 123 123 456 456 123 456 456 123

Вам также может понравиться