C# Test 3 Which of the following statements are TRUE about the .NET CLR? 1. It provides a language-neutral development & execution environment. 2. It ensures that an application would not be able to access memory that it is not authorized to access. 3. It provides services to run "managed" applications. 4. The resources are garbage collected. 5. It provides services to run "unmanaged" applications. Only 3 and 4 Only 4 and 5 Only 1, 2 and 4 1, 2, 3, 4 Only 1 and 2 Which of the following statements correctly define .NET Framework? It is an environment for development and execution of Windows applications. It is an environment for developing, building, deploying and executing Web Services. It is an environment for developing, building, deploying and executing Distributed Applications. It is an environment for developing, building, deploying and executing only Web Applications. It is an environment for developing, building, deploying and executing Desktop Applications, Web Applications and Web Services. Which of the following is the correct output for the C#.NET program given below? int i = 20 ; for( ; ; ) { Console.Write(i + " "); if (i >= -10) i -= 4; else break; } 16 12 8 4 0 20 16 12 84 0 -4 -8 20 16 12 8 4 0 20 16 12 8 4 0 -4 -8 -12 16 8 0 -8 Which of the following statements are correct? 1. A switch statement can act on numerical as well as Boolean types. 2. A switch statement can act on characters, strings and enumerations types. 3. We cannot declare variables within a case statement if it is not enclosed by { }. 4. 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. 5. All of the expressions of the for statement are not optional. 4, 5 3, 5 2, 3 1, 2 None of these Which of the following statements is correct about the C#.NET code snippet given below? switch (id) { case 6: grp = "Grp B"; break; case 13: grp = "Grp D"; break; case 1: grp = "Grp A"; break; case ls > 20: grp = "Grp E"; break ; case Else: grp = "Grp F"; break; } The order of the first three cases should be case 1, case 6, case 13 (ascending). Compiler will report an error as there is no default case. Compiler will report an error only in case Else. There is no error in this switch case statement. Compiler will report an error in case ls > 20 as well as in case Else. Which of the following are NOT Relational operators in C#.NET? 1. >= 2. != 3. Not 4. <= 5. = 3, 5 1, 3 2, 4 4, 5 None of these Which of the following statements are correct about functions used in C#.NET? 1. Function definitions cannot be nested. 2. Functions can be called recursively. 3. If we do not return a value from a function then a value -1 gets returned. 4. To return the control from middle of a function exit function should be used. 5. Function calls can be nested. 2, 3 2, 3, 5 1, 2, 5 4, 5 None of these Which of the following statements is correct about the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class Sample { public int func() { return 1; } public Single func() { return 2.4f ; } } class Program { static void Main(string[ ] args) { Sample s1 = new Sample(); int i; i = s1.func(); Single j; j = s1.func(); } } } The call j = s1.func() will assign 2.4 to j. The call to i = s1.func() will assign 1 to i. func() cannot be considered overloaded because: return value cannot be used to distinguish between two overloaded functions. Overloading works only in case of subroutines and not in case of functions. func() is a valid overloaded function. Which of the following statements is correct about constructors? If we do not provide a constructor, then the compiler provides a zero-argument constructor. Overloaded constructors cannot use optional arguments. Static constructors can use optional arguments. If we provide a one-argument constructor then the compiler still provides a zero-argument constructor. Which statement will you add in the function fun() of class B, if it is to produce the output "Welcome to IndiaBIX.com!"? namespace IndiabixConsoleApplication { class A { public void fun() { Console.Write("Welcome"); } } class B: A { public void fun() { // [*** Add statement here ***] Console.WriteLine(" to IndiaBIX.com!"); } } class MyProgram { static void Main (string[ ] args) { B b = new B(); b.fun(); } } } A.fun(); mybase.fun(); fun(); A::fun(); base.fun(); Which of the following statements is correct about the array declaration given below? int[][][] intMyArr = new int[2][][]; intMyArr refers to a 3-D jagged array containing 2 2-D rectangular arrays. intMyArr refers to a 3-D jagged array containing three 2-D jagged arrays. intMyArr refers to a 2-D jagged array containing 2 rows. intMyArr refers to a 2-D jagged array containing 3 rows. intMyArr refers to a 3-D jagged array containing 2 2-D jagged arrays. Which of the following will be the correct output for the C#.NET code snippet given below? String s1="Kicit"; Console.Write(s1.IndexOf('c') + " "); Console.Write(s1.Length); 2 6 3 6 3 5 2 5 3 7 Which of the following statements is correct about the C#.NET code snippet given below? class Trial { int i; Decimal d; } struct Sample { private int x; private Single y; private Trial z; } Sample ss = new Sample(); ss will be created on the stack. Both ss and z will be created on the heap. z will be created on the heap. Trial object referred by z will be created on the stack. ss will be created on the heap. Which of the following statements is true about an enum used in C#.NET? An enum variable cannot have a protected access modifier. An enum variable can be defined inside a class or a namespace. An enum variable cannot have a private access modifier. An enum variable cannot have a public access modifier. An implicit cast is needed to convert from enum type to an integral type. Which of the following will be the correct output for the C#.NET code snippet given below? enum color : int { red = -3, green, blue } Console.Write( (int) color.red + ", "); Console.Write( (int) color.green + ", "); Console.Write( (int) color.blue ); color.red, color.green, color.blue red, green, blue -3, -2, -1 -3, 0, 1 0, 1, 2 Which of the following statements are correct about the Stack collection? 1. It can be used for evaluation of expressions. 2. All elements in the Stack collection can be accessed using an enumerator. 3. It is used to maintain a FIFO list. 4. All elements stored in a Stack collection must be of similar type. 5. Top-most element of the Stack collection can be accessed using the Peek() method. 1, 2 and 5 only 1 and 2 only 3 and 4 only All of the above None of the above Which of the following statements are correct about a HashTable collection? 1. It is a keyed collection. 2. It is a ordered collection. 3. It is an indexed collection. 4. It implements a IDictionaryEnumerator interface in its inner class. 5. The key - value pairs present in a HashTable can be accessed using the Keys and Values properties of the inner class that implements the IDictionaryEnumerator interface. 1, 4 and 5 only 4 and 5 only 1, 2 and 3 only 1 and 2 only All of the above Which of the following statements is correct about properties used in C#.NET? A property has to be either read only or a write only. Properties of a class are actually methods that work like data members. Properties cannot be overloaded. Every property must have a set accessor and a get accessor. Which of the following statements is correct about the C#.NET program given below? using System; namespace IndiabixConsoleApplication { class MyProgram { static void Main(string[] args) { int index = 6; int val = 44; int[] a = new int[5]; try { a[index] = val ; } catch(IndexOutOfRangeException e) { Console.Write("Index out of bounds "); } Console.Write("Remaining program"); } } } It will output: Index out of bounds Remaining program It will not produce any output. It will output: Remaining program It will output: Index out of bounds Value 44 will get assigned to a[6]. Which of the following keyword is used to overload user-defined types by defining static member functions? udoperator operatoroverload operator opoverload op Schreibe einen Kommentar Antworten abbrechenDu musst angemeldet sein, um einen Kommentar abzugeben.