C# Test 4 Which of the following .NET components can be used to remove unused references from the managed heap? CTS Class Loader Garbage Collector CLR Common Language Infrastructure Which of the following assemblies can be stored in Global Assembly Cache? Protected Assemblies Public Assemblies Friend Assemblies Shared Assemblies Private Assemblies Which of the following does not store a sign? Single Byte Short Integer Long What will be the output of the following code snippet when it is executed? int x = 1; float y = 1.1f; short z = 1; Console.WriteLine((float) x + y * z - (x += (short) y)); 11 1.1 0.1 1.0 Which of the following statements is correct? A class can have more than one destructor. Destructors are used with classes as well as structures. C# provides a copy constructor. A constructor can be used to set default values and limit instantiation. Which of the following statements are correct about static functions? 1. Static functions can access only static data. 2. Static functions cannot call instance functions. 3. It is necessary to initialize static data. 4. Instance functions can call static functions and access static data. 5. this reference is passed to static functions. 4, 5 3, 4 2, 3, 5 1, 2, 4 None of these Which of the following statements are correct about the C#.NET code snippet given below? class Sample { static int i; int j; public void proc1() { i = 11; j = 22; } public static void proc2() { i = 1; j = 2; } static Sample() { i = 0; j = 0; } } proc1() can initialize i as well as j. The constructor can never be declared as static. proc2() can initialize i as well as j. j can be initialized in proc2(). i cannot be initialized in proc1(). Multiple inheritance is different from multiple levels of inheritance. False True The way a derived class member function can access base class public members, the base class member functions can access public member functions of derived class. False True Which of the following will be the correct output for the C#.NET code snippet given below? String s1 = "ALL MEN ARE CREATED EQUAL"; String s2; s2 = s1.Substring(12, 3); Console.WriteLine(s2); CREATED CR ARE CRE REA Which of the following statement is correct about a String in C#.NET? The System.Array class is used to represent a string. Methods of the String class can be used to modify the string. A number CANNOT be represented in the form of a String. A String is mutable because it can be modified once it has been created. A String has a zero-based index. Suppose on pushing a button an object is to be notified, but it is not known until runtime which object should be notified. Which of the following programming constructs should be used to implement this idea? Encapsulation Interface Delegate Namespace Attribute A HashTable t maintains a collection of names of states and capital city of each state. Which of the following is the correct way to find out whether "Kerala" state is present in this collection or not? t.ContainsValue("Kerala"); t.HasKey("Kerala"); t.ContainsState("Kerala"); t.HasValue("Kerala"); t.ContainsKey("Kerala"); Which of the following statements is correct about an Exception? It occurs during loading of the program. It occurs during Just-In-Time compilation. It occurs during compilation. It occurs during linking. It occurs at run-time. Which of the following statements is correct about the C#.NET program given below if a value "ABCD" is input to it? using System; namespace IndiabixConsoleApplication { class MyProgram { static void Main(string[] args) { int index; int vat = 88; int[] a = new int(5]; try { Console.Write("Enter a number: "); index = Convert.Toint32(Console.ReadLine()); a[index] = val; } catch(Exception e) { Console.Write("Exception occurred"); } Console.Write("Remaining program"); } } } The value 88 will get assigned to a[0]. It will output: Exception occurred Remaining program It will output: Remaining program Exception occurred It will output: Exception occurred It will output: Remaining program Which of the following is the correct way to overload + operator? public static sample operator + ( sample a, sample b ) public abstract operator + ( sample a, sample b) public sample operator + ( sample a, sample b ) public abstract sample operator + (sample a, sample b ) All of the above Which of the following statements is correct? If the method in the derived class is not preceded by override keywords, the compiler will issue a warning and the method will behave as if the override keyword were present. If a derived class does not provide its own version of virtual method then the one in the base class is used. By default methods are virtual. Only one object can be created from an abstract class. Each derived class does not have its own version of a virtual method. Schreibe einen Kommentar Antworten abbrechenDu musst angemeldet sein, um einen Kommentar abzugeben.