Sie sind auf Seite 1von 138

Arrays

1. Which of the following statements are correct about the C#.NET code snippet given below? int[ , ] intMyArr = {{7, 1, 3}, {2, 9, 6}}; 1. 2. 3. 4. 5. intMyArr represents rectangular array of 2 rows and 3 columns. intMyArr.GetUpperBound(1) will yield 2. intMyArr.Length will yield 24. intMyArr represents 1-D array of 5 integers. intMyArr.GetUpperBound(0) will yield 2.

2. Which of the following statements are correct about the C#.NET code snippet given below? int[] a = {11, 3, 5, 9, 4}; 1. 2. 3. 4. The array elements are created on the stack. Refernce a is created on the stack. The array elements are created on the heap. On declaring the array a new array class is created which is derived from System.Array Class. 5. Whether the array elements are stored in the stack or heap depends upon the size of the array.

3. Which one of the following statements is correct? A.Array elements can be of integer type only. B. The rank of an Array is the total number of elements it can contain. C. The length of an Array is the number of dimensions in the Array. D.The default value of numeric array elements is zero. E. The Array elements are guaranteed to be sorted.

If a is an array of 5 integers then which of the following is the correct way to increase its size to 10 elements?

A.

int[] a = new int[5]; int[] a = new int[10];

int[] a = int[5]; B. int[] a = int[10]; int[] a = new int[5]; C. a.Length = 10 ;

int[] a = new int[5]; D.a = new int[10];

E.

int[] a = new int[5]; a.GetUpperBound(10);

5. How will you complete the foreach loop in the C#.NET code snippet given below such that it correctly prints all elements of the array a? int[][]a = new int[2][]; a[0] = new int[4]{6, 1 ,4, 3}; a[1] = new int[3]{9, 2, 7}; foreach (int[ ] i in a) { /* Add loop here */ Console.Write(j + " "); Console.WriteLine(); } A.foreach (int j = 1; j < a(0).GetUpperBound; j++) B. foreach (int j = 1; j < a.GetUpperBound (0); j++) C. foreach (int j in a.Length) D.foreach (int j in i) E. foreach (int j in a.Length -1)

6. Which of the following is the correct output of the C#.NET code snippet given below? int[ , , ] a = new int[ 3, 2, 3 ]; Console.WriteLine(a.Length);

A.20 C. 18 E. 5

B. 4 D.10

7. Which of the following statements are correct about arrays used in C#.NET? 1. 2. 3. 4. 5. Arrays can be rectangular or jagged. Rectangular arrays have similar rows stored in adjacent memory locations. Jagged arrays do not have an access to the methods of System.Array Class. Rectangular arrays do not have an access to the methods of System.Array Class. Jagged arrays have dissimilar rows stored in non-adjacent memory locations.

8. Which of the following statements are correct about the C#.NET code snippet given below? int[][]intMyArr = new int[2][]; intMyArr[0] = new int[4]{6, 1, 4, 3}; intMyArr[1] = new int[3]{9, 2, 7}; A.intMyArr is a reference to a 2-D jagged array. B. The two rows of the jagged array intMyArr are stored in adjacent memory locations. intMyArr[0] refers to the zeroth 1-D array and intMyArr[1] refers to the first 1-D C. array. D.intMyArr refers to intMyArr[0] and intMyArr[1] . E. intMyArr refers to intMyArr[1] and intMyArr[2] .

9. Which of the following are the correct ways to define an array of 2 rows and 3 columns? 1. int[ , ] a; 2. a = new int[2, 3]{{7, 1, 3},{2, 9, 6}}; 3. 4. int[ , ] a;

5. a = new int[2, 3]{}; 6. 7. int[ , ] a = {{7, 1, 3}, {2, 9,6 }}; 8. 9. int[ , ] a; 10. a = new int[1, 2]; 11. 12. int[ , ] a; 13. a = new int[1, 2]{{7, 1, 3}, {2, 9, 6}};

Which of the following statements is correct about the array declaration given below? int[][][] intMyArr = new int[2][][]; A.intMyArr refers to a 2-D jagged array containing 2 rows. B. intMyArr refers to a 2-D jagged array containing 3 rows. C.intMyArr refers to a 3-D jagged array containing 2 2-D jagged arrays. D.intMyArr refers to a 3-D jagged array containing three 2-D jagged arrays. E. intMyArr refers to a 3-D jagged array containing 2 2-D rectangular arrays.

11. Which of the following statements is correct about the C#.NET code snippet given below? int[] intMyArr = {11, 3, 5, 9, 4}; A.intMyArr is a reference to an object of System.Array Class. intMyArr is a reference to an object of a class that the compiler derives from B. System.Array Class. C. intMyArr is a reference to an array of integers. D.intMyArr is a reference to an object created on the stack. E. intMyArr is a reference to the array created on the stack.

12. Which of the following is the correct way to define and initialise an array of 4 integers? int[] a = {25, 30, 40, 5}; int[] a; a = new int[3]; a[0] = 25;

a[1] = 30; a[2] = 40; a[3] = 5; int[] a; a = new int{25, 30, 40, 5}; int[] a; a = new int[4]{25, 30, 40, 5};

int[] a; a = new int[4]; a[0] = 25; a[1] = 30; a[2] = 40; a[3] = 5;

13. Which of the following is the correct output of the C#.NET code snippet given below? int[][] a = new int[2][]; a[0] = new int[4]{6, 1, 4, 3}; a[1] = new int[3]{9, 2, 7}; Console.WriteLine(a[1].GetUpperBound(0)); //arrays total elements ..means arrays last number.. A.3 B. 4 C. 7 D.9 E. 2

14. Which of the following is the correct way to obtain the number of elements present in the array given below? int[] intMyArr = {25, 30, 45, 15, 60}; 1. 2. 3. 4. 5. intMyArr.GetMax; intMyArr.Highest(0); intMyArr.GetUpperBound(0); intMyArr.Length; intMyArr.GetMaxElements(0);

15. What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class SampleProgram { static void Main(string[ ] args) { int i, j; int[ , ] arr = new int[ 2, 2 ]; for(i = 0; i < 2; ++i) { for(j = 0; j < 2; ++j) { arr[i, j] = i * 17 + i * 17; Console.Write(arr[ i, j ] + " "); } } } } } A.0 0 34 34 B. 0 0 17 17 C. 0 0 0 0 D.17 17 0 0 E. 34 34 0 0

.Net Framework

1. 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.

Which of the following are valid .NET CLR JIT performance counters? 1. 2. 3. 4. 5. Total memory used for JIT compilation Average memory used for JIT compilation Number of methods that failed to compile with the standard JIT Percentage of processor time spent performing JIT compilation Percentage of memory currently dedicated for JIT compilation

3. Which of the following statements is correct about Managed Code? A.Managed code is the code that is compiled by the JIT compilers. B. Managed code is the code where resources are Garbage Collected. C. Managed code is the code that runs on top of Windows. D.Managed code is the code that is written to target the services of the CLR. E. Managed code is the code that can run on top of Linux.

4. Which of the following utilities can be used to compile managed assemblies into processor-specific native code? A.gacutil B. ngen C. sn D.dumpbin E. ildasm

5. Which of the following are NOT true about .NET Framework? 1. It provides a consistent object-oriented programming environment whether object code is stored and executed locally, executed locally but Internetdistributed, or executed remotely. 2. It provides a code-execution environment that minimizes software deployment and versioning conflicts. 3. It provides a code-execution environment that promotes safe execution of code, including code created by an unknown or semi-trusted third party. 4. It provides different programming models for Windows-based applications and Web-based applications. 5. It provides an event driven programming model for building Windows Device Drivers.

6. Which of the following components of the .NET framework provide an extensible set of classes that can be used by any .NET compliant programming language? A..NET class libraries B. Common Language Runtime C. Common Language Infrastructure D.Component Object Model E. Common Type System

7. Which of the following jobs are NOT performed by Garbage Collector? 1. 2. 3. 4. 5. Freeing memory on the stack. Avoiding memory leaks. Freeing memory occupied by unreferenced objects. Closing unclosed database collections. Closing unclosed files.

8. Which of the following .NET components can be used to remove unused references from the managed heap? A.Common Language Infrastructure B. CLR C. Garbage Collector D.Class Loader E. CTS

9. Which of the following statements correctly define .NET Framework? It is an environment for developing, building, deploying and executing Desktop A. Applications, Web Applications and Web Services. It is an environment for developing, building, deploying and executing only Web B. Applications. It is an environment for developing, building, deploying and executing Distributed C. Applications. It is an environment for developing, building, deploying and executing Web D. Services. E. It is an environment for development and execution of Windows applications.

10. Which of the following constitutes the .NET Framework? 1. 2. 3. 4. 5. ASP.NET Applications CLR Framework Class Library WinForm Applications Windows Services

11. Which of the following assemblies can be stored in Global Assembly Cache? A.Private Assemblies B. Friend Assemblies C.Shared Assemblies D.Public Assemblies E. Protected Assemblies

12. Code that targets the Common Language Runtime is known as A.Unmanaged B. Distributed C. Legacy D.Managed Code E. Native Code

13. Which of the following statements is correct about the .NET Framework? A..NET Framework uses DCOM for achieving language interoperability. B. .NET Framework is built on the DCOM technology. .NET Framework uses DCOM for making transition between managed and C. unmanaged code. D..NET Framework uses DCOM for creating unmanaged applications. E. .NET Framework uses COM+ services while creating Distributed Applications.

14. Which of the following is the root of the .NET type hierarchy? A.System.Object B. System.Type C. System.Base D.System.Parent E. System.Root

15. Which of the following benefits do we get on running managed code under CLR? 1. Type safety of the code running under CLR is assured. 2. It is ensured that an application would not access the memory that it is not authorized to access. 3. It launches separate process for every application running under it. 4. The resources are Garbage collected.

16. Which of the following security features can .NET applications avail? 1. 2. 3. 4. 5. PIN Security Code Access Security Role Based Security Authentication Security Biorhythm Security

17. Which of the following jobs are done by Common Language Runtime? 1. It provides core services such as memory management, thread management, and remoting. 2. It enforces strict type safety. 3. It provides Code Access Security. 4. It provides Garbage Collection Services.

18. Which of the following statements are correct about a .NET Assembly? 1. It is the smallest deployable unit. 2. Each assembly has only one entry point - Main(), WinMain() or DLLMain(). 3. An assembly can be a Shared assembly or a Private assembly. 4. An assembly can contain only code and data. 5. An assembly is always in the form of an EXE file. 19. Which of the following statements are correct about JIT? 1. JIT compiler compiles instructions into machine code at run time. 2. The code compiler by the JIT compiler runs under CLR. 3. The instructions compiled by JIT compilers are written in native code. 4. The instructions compiled by JIT compilers are written in Intermediate Language (IL) code. 5. The method is JIT compiled even if it is not called

20. Which of the following are parts of the .NET Framework? 1. 2. 3. 4. 5. The Common Language Runtime (CLR) The Framework Class Libraries (FCL) Microsoft Published Web Services Applications deployed on IIS Mobile Applications

Classes and Objects

1. Which of the following statements is correct about the C#.NET code snippet given below? class Student s1, s2; // Here 'Student' is a user-defined class. s1 = new Student(); s2 = new Student(); A.Contents of s1 and s2 will be exactly same. B. The two objects will get created on the stack. C. Contents of the two objects created will be exactly same. D.The two objects will always be created in adjacent memory locations. E. We should use delete() to delete the two objects from memory.

2. Which of the following statements is correct about the C#.NET code snippet given below? class Sample { private int i; public Single j; private void DisplayData() { Console.WriteLine(i + " " + j); } public void ShowData() { Console.WriteLine(i + " " + j); } } A.j cannot be declared as public. B. DisplayData() cannot be declared as private. C. DisplayData() cannot access j. D.ShowData() cannot access to i. E. There is no error in this class.

3. Which of the following statements are correct? 1. Instance members of a class can be accessed only through an object of that class.

2. A class can contain only instance data and instance member function. 3. All objects created from a class will occupy equal number of bytes in memory. 4. A class can contain Friend functions. 5. A class is a blueprint or a template according to which objects are created.

4. Which of the following statements is correct? Procedural Programming paradigm is different than structured programming A. paradigm. Object Oriented Programming paradigm stresses on dividing the logic into smaller B. parts and writing procedures for each part. C. Classes and objects are corner stones of structured programming paradigm. Object Oriented Programming paradigm gives equal importance to data and D. the procedures that work on the data. E. C#.NET is a structured programming language. 5. Which of the following is the correct way to create an object of the class Sample? 1. 2. 3. 4. Sample s = new Sample(); Sample s; Sample s; s = new Sample(); s = new Sample();

Which of the following will be the correct output for the C#.NET program given below? namespace IndiabixConsoleApplication { class Sample { int i; Single j; public void SetData(int i, Single j) { i = i; j = j; ///assignment to same variable meansmeans assign something else } public void Display() { Console.WriteLine(i + " " + j);

} } class MyProgram { static void Main(string[ ] args) { Sample s1 = new Sample(); s1.SetData(10, 5.4f); s1.Display(); } } } A.0 0 B. 10 5.4 C. 10 5.400000 D.10 5 E. None of the above 7. The this reference gets created when a member function (non-shared) of a class is called. A.True B.False 8. Which of the following statements are correct? 1. 2. 3. 4. 5. Data members of a class are by default public. Data members of a class are by default private. Member functions of a class are by default public. A private function of a class can access a public function within the same class. Member function of a class are by default private.

9. Which of the following statements is correct about the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class Sample { public int index; public int[] arr = new int[10]; public void fun(int i, int val) { arr[i] = val; }

} class MyProgram { static void Main(string[] args) { Sample s = new Sample(); s.index = 20; Sample.fun(1, 5); s.fun(1, 5); } } } A.s.index = 20 will report an error since index is public. B. The call s.fun(1, 5) will work correctly. C. Sample.fun(1, 5) will set a value 5 in arr[ 1 ] . D.The call Sample.fun(1, 5) cannot work since fun() is not a shared function. E. arr being a data member, we cannot declare it as public.

10. Which of the following statements are correct about the C#.NET code snippet given below? sample c; c = new sample(); 1. 2. 3. 4. It will create an object called sample. It will create a nameless object of the type sample. It will create an object of the type sample on the stack. It will create a reference c on the stack and an object of the type sample on the heap. 5. It will create an object of the type sample either on the heap or on the stack depending on the size of the object.

11. Which of the following statements is correct about the C#.NET code snippet given below? int i; int j = new int(); i = 10; j = 20; String str; str = i.ToString(); str = j.ToString(); A.This is a perfectly workable code snippet.

B. Since int is a primitive, we cannot use new with it. C. Since an int is a primitive, we cannot call the method ToString() using it. D.i will get created on stack, whereas j will get created on heap. E. Both i and j will get created on heap.

12. Which of the following statements are correct about the this reference? 1. 2. 3. 4. this reference can be modified in the instance member function of a class. Static functions of a class never receive the this reference. Instance member functions of a class always receive a this reference. this reference continues to exist even after control returns from an instance member function. 5. While calling an instance member function we are not required to pass the this reference explicitly.

Which of the following will be the correct output for the C#.NET program given below? namespace IndiabixConsoleApplication { class Sample { int i; Single j; public void SetData(int i, Single j) { this.i = i; this.j = j; } public void Display() { Console.WriteLine(i + " " + j); } } class MyProgram { static void Main(string[ ] args) { Sample s1 = new Sample(); s1.SetData(36, 5.4f); s1.Display();

} } } A.0 0.0 B. 36 5.4 C. 36 5.400000 D.36 5 E. None of the above

14. Which of the following statements are correct about objects of a user-defined class called Sample? 1. All objects of Sample class will always have exactly same data. 2. Objects of Sample class may have same or different data. 3. Whether objects of Sample class will have same or different data depends upon a Project Setting made in Visual Studio.NET. 4. Conceptually, each object of Sample class will have instance data and instance member functions of the Sample class. 5. All objects of Sample class will share one copy of member functions.

15. Which of the following statements are correct about the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class Sample { int i, j; public void SetData(int ii, int jj) { this.i = ii; this.j = jj } } class MyProgram { static void Main(string[ ] args) { Sample s1 = new Sample(); s1.SetData(10, 2); Sample s2 = new Sample(); s2.SetData(5, 10); } }

} A.The code will not compile since we cannot explicitly use this. B. Using this in this program is necessary to properly set the values in the object. C. The call to SetData() is wrong since we have not explicitly passed the this reference to it. The definition of SetData() is wrong since we have not explicitly collected the this D. reference. E. Contents of this will be different during each call to SetData().

16. Which of the following statements is correct about classes and objects in C#.NET? A.Class is a value type. B. Since objects are typically big in size, they are created on the stack. C. Objects of smaller size are created on the heap. D.Smaller objects that get created on the stack can be given names. E. Objects are always nameless.

Constructor 1. Which of the following statements is correct? A.A constructor can be used to set default values and limit instantiation. B. C# provides a copy constructor. C. Destructors are used with classes as well as structures. D.A class can have more than one destructor. 2. 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(); } } } A.func() is a valid overloaded function. B. Overloading works only in case of subroutines and not in case of functions. func() cannot be considered overloaded because: return value cannot be used to C. distinguish between two overloaded functions. D.The call to i = s1.func() will assign 1 to i. E. The call j = s1.func() will assign 2.4 to j.

3. Which of the following ways to create an object of the Sample class given below will work correctly? class Sample { int i; Single j; double k; public Sample (int ii, Single jj, double kk) { i = ii; j = jj; k = kk; } } A.Sample s1 = new Sample(); B. Sample s1 = new Sample(10); C. Sample s2 = new Sample(10, 1.2f); D.Sample s3 = new Sample(10, 1.2f, 2.4); E. Sample s1 = new Sample(, , 2.5); 4. 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.

5. Which of the following statements is correct about constructors? If we provide a one-argument constructor then the compiler still provides a zero-argument A. constructor. B. Static constructors can use optional arguments. C. Overloaded constructors cannot use optional arguments. If we do not provide a constructor, then the compiler provides a zero-argument D. constructor.

6. Which of the following is the correct way to define the constructor(s) of the Sample class if we are to create objects as per the C#.NET code snippet given below? Sample s1 = new Sample(); Sample s2 = new Sample(9, 5.6f); public Sample() { i = 0; j = 0.0f; } A.public Sample (int ii, Single jj) { i = ii; j = jj; }

public Sample (Optional int ii = 0, Optional Single jj = 0.0f) { B. i = ii; j = jj; }

C. public Sample (int ii, Single jj) {

i = ii; j = jj; }

D.Sample s; s = new Sample();

E.

7. In which of the following should the methods of a class differ if they are to be treated as overloaded methods? 1. 2. 3. 4. 5. Type of arguments Return type of methods Number of arguments Names of methods Order of arguments

8. Can static procedures access instance data? A.Yes B.No

9. Which of the following statements are correct about constructors in C#.NET? 1. 2. 3. 4. 5. Constructors cannot be overloaded. Constructors always have the name same as the name of the class. Constructors are never called explicitly. Constructors never return any value. Constructors allocate space for the object in memory.

10. How many times can a constructor be called during lifetime of the object? A.As many times as we call it. B. Only once. C. Depends upon a Project Setting made in Visual Studio.NET. D.Any number of times before the object gets garbage collected. E. Any number of times before the object is deleted. 11. Is it possible to invoke Garbage Collector explicitly? No A.Yes B.

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() { 12. i = 1; j = 2; } static Sample() { i = 0; j = 0; } } A.i cannot be initialized in proc1(). B. proc1() can initialize i as well as j. C.j can be initialized in proc2(). D.The constructor can never be declared as static. E. proc2() can initialize i as well as j. 13. Which of the following statements is correct? A.There is one garbage collector per program running in memory. B. There is one common garbage collector for all programs. An object is destroyed by the garbage collector when only one reference refers to C. it. We have to specifically run the garbage collector after executing Visual D. Studio.NET. 14. Is it possible for you to prevent an object from being created by using zero argument constructor? B.No A.Yes 15. Which of the following statements are correct about static functions? A.Static functions are invoked using objects of a class. B. Static functions can access static data as well as instance data. C. Static functions are outside the class scope. D.Static functions are invoked using class.

16. What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class Sample { static Sample() { Console.Write("Sample class "); } public static void Bix1() { Console.Write("Bix1 method "); } } class MyProgram { static void Main(string[ ] args) { Sample.Bix1(); } } } A.Sample class Bix1 method B. Bix1 method C. Sample class D.Bix1 method Sample class E. Sample class Sample class

17. Which of the following statements is correct about constructors in C#.NET? A.A constructor cannot be declared as private. B. A constructor cannot be overloaded. C. A constructor can be a static constructor. D.A constructor cannot access static data. E. this reference is never passed to a constructor. 18. What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class Sample { public static void fun1() { Console.WriteLine("Bix1 method");

} public void fun2() { fun1(); Console.WriteLine("Bix2 method"); } public void fun2(int i) { Console.WriteLine(i); fun2(); } } class MyProgram { static void Main(string[ ] args) { Sample s = new Sample(); Sample.fun1(); s.fun2(123); } } } Bix1 method 123 Bixl method A. Bix2 method

Bix1 method 123 B. Bix2 method

Bix2 method 123 C. Bix2 method Bixl method

Bixl method D.123

Bix2 method E. 123 Bixl method

Strings 1. Which of the following statements are true about the C#.NET code snippet given below? String s1, s2; s1 = "Hi"; s2 = "Hi"; 1. 2. 3. 4. 5. String objects cannot be created without using new. Only one object will get created. s1 and s2 both will refer to the same object. Two objects will get created, one pointed to by s1 and another pointed to by s2. s1 and s2 are references to the same object.

2.

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);

A.ARE C. CR E. CREATED

B. CRE D.REA

3. Which of the following statements will correctly copy the contents of one string into another ? String s1 = "String"; String s2; A. s2 = s1; String s1 = "String" ; String s2; B. s2 = String.Concat(s1, s2);

String s1 = "String"; String s2; C. s2 = String.Copy(s1); String s1 = "String"; String s2; D. s2 = s1.Replace(); String s1 = "String"; E. String s2; s2 = s2.StringCopy(s1); The string built using the String class are immutable (unchangeable), whereas, the ones built- using the StringBuilder class are mutable. B.False A.True

5. Which of the following will be the correct output for the C#.NET code snippet given below? String s1 = "Nagpur"; String s2; s2 = s1.Insert(6, "Mumbai"); Console.WriteLine(s2); A.NagpuMumbair B. Nagpur Mumbai C. Mumbai D.Nagpur E. NagpurMumbai

6. If s1 and s2 are references to two strings, then which of the following is the correct way to compare the two references? A.s1 is s2 B. s1 = s2 C. s1 == s2 D.strcmp(s1, s2) E. s1.Equals(s2)

7. What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class SampleProgram { static void Main(string[ ] args) { string str= "Hello World!"; Console.WriteLine( String.Compare(str, "Hello World?" ).GetType() ); } } } A.0 B. 1 C. String D.Hello World? E. System.Int32

8. Which of the following snippets are the correct way to convert a Single into a String? 1 Single f = 9.8f; String s; s = (String) (f); 2 Single f = 9.8f; String s; s = Convert.ToString(f); 3 Single f = 9.8f; String s; s = f.ToString(); 4 Single f = 9.8f; String s; s = Clnt(f);

5 Single f = 9.8f; String s; s = CString(f); 9. 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); A.3 6 B. 2 5 C. 3 5 D.2 6 E. 3 7 10. Which of the following is correct way to convert a String to an int? 1 String s = "123"; int i; i = (int)s; 2 String s = "123"; int i; i = int.Parse(s); 3 String s = "123"; int i; i = Int32.Parse(s); 4 String s = "123"; int i; i = Convert.ToInt32(s); 5 String s = "123"; int i; i = CInt(s); 11. Which of the following statements about a String is correct? A.A String is created on the stack. B. Whether a String is created on the stack or the heap depends on the length of the String. C. A String is a primitive. D.A String can be created by using the statement String s1 = new String; E. A String is created on the heap.

12. Which of the following statement is correct about a String in C#.NET?

A.A String is mutable because it can be modified once it has been created. B. Methods of the String class can be used to modify the string. C. A number CANNOT be represented in the form of a String. D.A String has a zero-based index. E. The System.Array class is used to represent a string. 13. Which of the following will be the correct output for the C#.NET code snippet given below? String s1 = "Five Star"; String s2 = "FIVE STAR"; int c; c = s1.CompareTo(s2); Console.WriteLine(c); A.0 C. 2 E. -2 B. 1 D.-1

14. If s1 and s2 are references to two strings then which of the following are the correct ways to find whether the contents of the two strings are equal? 1. if(s1 = s2) 2. if(s1 == s2)

3. int c; c = s1.CompareTo(s2); 4. if( strcmp(s1, s2) ) 5 if (s1 is s2) 15. Which of the following statements are correct about the String Class in C#.NET? 1. 2. 3. 4. 5. Two strings can be concatenated by using an expression of the form s3 = s1 + s2; String is a primitive in C#.NET. A string built using StringBuilder Class is Mutable. A string built using String Class is Immutable. Two strings can be concatenated by using an expression of the form s3 = s1&s2;

16. Which of the following statements are correct? 1. String is a value type. 2. String literals can contain any character literal including escape sequences. 3. The equality operators are defined to compare the values of string objects as well as references. 4. Attempting to access a character that is outside the bounds of the string results in an IndexOutOfRangeException. 5. The contents of a string object can be changed after the object is created.

17. Which of the following is the correct way to find out the index of the second 's' in the string "She sells sea shells on the sea-shore"? String str = "She sells sea shells on the sea-shore"; Aint i; . i = str.SecondIndexOf("s");

String str = "She sells sea shells on the sea-shore"; Bint i, j; . i = str.FirstIndexOf("s"); j = str.IndexOf("s", i + 1);

String str = "She sells sea shells on the sea-shore"; C int i, j; . i = str.IndexOf("s"); j = str.IndexOf("s", i + 1); String str = "She sells sea shells on the sea-shore"; D int i, j; . i = str.LastIndexOf("s"); j = str.IndexOf("s", i - 1); String str = "She sells sea shells on the sea-shore"; E int i, j; . i = str.IndexOf("S"); j = str.IndexOf("s", i);

Polymorphism 1. Which of the following unary operators can be overloaded? 1. 2. 3. 4. 5. true false + new is

2. A derived class can stop virtual inheritance by declaring an override as A.inherits B. extends C. inheritable D.not inheritable E. sealed

3. Which of the following keyword is used to change the data and behavior of a base class by replacing a member of a base class with a new derived member? A.new B. base C. overloads D.override E. overridable

4. Which of the following statements is correct? When used as a modifier, the new keyword explicitly hides a member inherited A. from a base class. B. Operator overloading works in different ways for structures and classes. C. It is not necessary that all operator overloads are static methods of the class. D.The cast operator can be overloaded.

5. Which of the following keyword is used to overload user-defined types by defining static member functions? A.op B. opoverload C.operator D.operatoroverload E. udoperator

6. Which of the followings is the correct way to overload + operator? A.public sample operator + ( sample a, sample b ) B. public abstract operator + ( sample a, sample b) C. public abstract sample operator + (sample a, sample b ) D.public static sample operator + ( sample a, sample b ) E. All of the above

7. Which of the following statements is correct? A.Static methods can be a virtual method. B. Abstract methods can be a virtual method. C. It is necessary to override a virtual method. When overriding a method, the names and type signatures of the override D. method must be the same as the virtual method that is being overriden. E. We can override virtual as well as non-virtual methods.

8. Which of the following statements are correct? 1. All operators in C#.NET can be overloaded. 2. We can use the new modifier to modify a nested type if the nested type is hiding another type. 3. In case of operator overloading all parameters must be of the different type than the class or struct that declares the operator. 4. Method overloading is used to create several methods with the same name that performs similar tasks on similar data types. 5. Operator overloading permits the use of symbols to represent computations for a type.

9. Which of the following statement is correct about the C#.NET code snippet given below? public class Sample { public int x; public virtual void fun() {} } public class DerivedSample : Sample { new public void fun() {}

} A.DerivedSample class hides the fun() method of base class. The DerivedSample class version of fun() method gets called using Sample class B. reference which holds DerivedSample class object. The code replaces the DerivedSample class version of fun() method with its Sample C. class version. It is not possible to hide Sample class version of fun() method without use of new in D. DerivedSample class.

10. Which of the following statements is correct? A.The conditional logical operators cannot be overloaded. When a binary operator is overloaded the corresponding assignment operator, if B. any, must be explicitly overloaded. We can use the default equality operator in an overloaded implementation of the C. equality operator. D.A public or nested public reference type does not overload the equality operator. E. The array indexing operator can be overloaded.

11. Which of the following operators cannot be overloaded? 1. 2. 3. 4. 5. true false new ~ sizeof

12. Which of the following modifier is used when a virtual method is redefined by a derived class? A.overloads B. override C. overridable D.virtual Base E. 13.In order for an instance of a derived class to completely take over a class member from a base class, the base class has to declare that member as A.new B. base C.virtual D.overrides E. overloads

14. Which of the following can be declared as a virtual in a class? 1. 2. 3. 4. 5. Methods Properties Events Fields Static fields

15. Which of the following statements is correct? A.Only one object can be created from an abstract class. B. By default methods are virtual. If a derived class does not provide its own version of virtual method then the one in C. the base class is used. If the method in the derived class is not preceded by override keywords, the compiler will D. issue a warning and the method will behave as if the override keyword were present. E. Each derived class does not have its own version of a virtual method. 16. Which of the following are necessary for Run-time Polymorphism? 1. The overridden base method must be virtual, abstract or override. 2. Both the override method and the virtual method must have the same access level modifier. 3. An override declaration can change the accessibility of the virtual method. 4. An abstract inherited property cannot be overridden in a derived class. 5. An abstract method is implicitly a virtual method.

Control Instructions 1. What does the following C#.NET code snippet will print? int i = 0, j = 0; label: i++; j+=i; if (i < 10) { Console.Write(i +" "); goto label; } A.Prints 1 to 9 B. Prints 0 to 8 C. Prints 2 to 8 D.Prints 2 to 9 E. Compile error at label:.

2. 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; } A.20 16 12 84 0 -4 -8 B. 20 16 12 8 4 0 C. 20 16 12 8 4 0 -4 -8 -12 D.16 12 8 4 0 E. 16 8 0 -8

3. Which of the following statements is correct? It is not possible to extend the if statement to handle multiple conditions using the A. else-if arrangement. The switch statement can include any number of case instances with two case B. statements having the same value. C. A jump statement such as a break is required after each case block excluding the last

block if it is a default statement. The if statement selects a statement for execution based on the value of a Boolean expression. E. C# always supports an implicit fall through from one case label to another. D.

4. What is the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { public enum color { red, green, blue }; class SampleProgram { static void Main (string[ ] args) { color c = color.blue; switch (c) { case color.red: Console.WriteLine(color.red); break; case color.green: Console.WriteLine(color.green); break; case color.blue: Console.WriteLine(color.blue); break; } } } }

A.red C. 0 E. 2

B. blue D.1

5. Which of the following is the correct way to rewrite the following C#.NET code snippet given below? int i = 0; do { Console.WriteLine(i); i+ = 1; } while (i <= 10);

int i = 0; do { Console.WriteLine(i); } until (i <= 10);

int i; for (i = 0; i <= 10 ; i++) Console.WriteLine(i);

int i = 0; while (i <= 11) { Console.WriteLine(i); i += 1; }

int i = 0; do while ( i <= 10) { Console.WriteLine(i); i += 1; }

int i = 0; do until (i <= 10) { Console.WriteLine(i); i+=1; }

6. What will be the output of the C#.NET code snippet given below? int val; for (val = -5; val <= 5; val++) { switch (val) { case 0: Console.Write ("India"); break; } if (val > 0) Console.Write ("B"); else if (val < 0) Console.Write ("X"); } A.XXXXXIndia C. XXXXXIndiaBBBBB E. Zero B. IndiaBBBBB D.BBBBBIndiaXXXXX

7. What will be the output of the C#.NET code snippet given below? char ch = Convert.ToChar ('a' | 'b' | 'c'); switch (ch) { case 'A': case 'a': Console.WriteLine ("case A | case a"); break; case 'B':

case 'b': Console.WriteLine ("case B | case b"); break; case 'C': case 'c': case 'D': case 'd': Console.WriteLine ("case D | case d"); break; } A.case A | case a B. case B | case b C. case D | case d D.Compile Error E. No output

8. Which of the following is the incorrect form of Decision Control instruction? if (Condition1) {// Some statement} if (Condition1) {// Some statement} else {// Some statement} if (Condition1) {// Some statement} else {// Some statement} else if ( Condition2){//Some statement} if ( Condition1 ) {// Some statement} else if ( Condition2 ) {// Some statement} else {// Some statement} if ( Condition1 ) {// Some statement} else if ( Condition2 ) {// Some statement} else if ( Condition3 ) {// Some statement} else {// Some statement} 9. Which of the following code snippets are the correct way to determine whether a is Odd or Even? int a; String res; if (a % 2 == 0) res = "Even"; else

res = "Odd";

int a; String res; if (a Mod 2 == 0) res = "Even"; else res = "Odd";

int a; Console.WriteLine(a Mod 2 == 0 ? "Even": "Odd");

int a; String res; a % 2 == 0 ? res = "Even" : res = "Odd"; Console.WriteLine(res);

10. Which of the following can be used to terminate a while loop and transfer control outside the loop? 1. 2. 3. 4. 5. exit while continue exit statement break goto

11. The C#.NET code snippet given below generates ____ numbers series as output? int i = 1, j = 1, val; while (i < 25) { Console.Write(j + " "); val = i + j; j = i; i = val;

} A.Prime C. Palindrome E. Even

B. Fibonacci D.Odd

12. Which of the following statements are correct about the C#.NET code snippet given below? if (age > 18 && no < 11) a = 25; 1. 2. 3. 4. 5. The condition no < 11 will be evaluated only if age > 18 evaluates to True. The statement a = 25 will get executed if any one condition is True. The condition no < 11 will be evaluated only if age > 18 evaluates to False. The statement a = 25 will get executed if both the conditions are True. && is known as a short circuiting logical operator.

13. Which of the following statements are correct? 1. 2. 3. 4. A switch statement can act on numerical as well as Boolean types. A switch statement can act on characters, strings and enumerations types. We cannot declare variables within a case statement if it is not enclosed by { }. 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.

13. Which of the following statements are correct? 1. 2. 3. 4. A switch statement can act on numerical as well as Boolean types. A switch statement can act on characters, strings and enumerations types. We cannot declare variables within a case statement if it is not enclosed by { }. 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.

14. What will be the output of the C#.NET code snippet given below? int i = 2, j = i; if (Convert.ToBoolean((i | j & 5) & (j - 25 * 1))) Console.WriteLine(1); else Console.WriteLine(0); A.0 B. 1 C. Compile Error D.Run time Error

15. 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; } A.Compiler will report an error in case ls > 20 as well as in case Else. B. There is no error in this switch case statement. C. Compiler will report an error only in case Else. D.Compiler will report an error as there is no default case. E. The order of the first three cases should be case 1, case 6, case 13 (ascending). 16. Which of the following is another way to rewrite the code snippet given below? int a = 1, b = 2, c = 0; if (a < b) c = a;

A.

int a = 1, b = 2, c = 0; c = a < b ? a : 0;

int a = 1, b = 2, c = 0; B. a < b ? c = a : c = 0;

int a = 1, b = 2, c = 0; C. a < b ? c = a : c = 0 ? 0 : 0;

int a = 1, b = 2, c = 0; D.a < b ? return (c): return (0);

E.

int a = 1, b = 2,c = 0; c = a < b : a ? 0;

17. Which of the following statements are correct? 1. 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. 2. The goto statement passes control to the next iteration of the enclosing iteration statement in which it appears.

3. Branching is performed using jump statements which cause an immediate transfer of the program control. 4. A common use of continue is to transfer control to a specific switch-case label or the default label in a switch statement. 5. The do statement executes a statement or a block of statements enclosed in {} repeatedly until a specified expression evaluates to false.

18. Which of the following statements are correct about the C#.NET code snippet given below? if (age > 18 || no < 11) a = 25; 1. The condition no < 11 will get evaluated only if age > 18 evaluates to False. 2. The condition no < 11 will get evaluated if age > 18 evaluates to True. 3. The statement a = 25 will get evaluated if any one one of the two conditions is True. 4. || is known as a short circuiting logical operator. 5. The statement a = 25 will get evaluated only if both the conditions are True.

19. What will be the output of the code snippet given below? int i; for(i = 0; i<=10; i++) { if(i == 4) { Console.Write(i + " "); continue; } else if (i != 4) Console.Write(i + " "); else break; } A.1 2 3 4 5 6 7 8 9 10

B. 1 2 3 4 C. 0 1 2 3 4 5 6 7 8 9 10 D.4 5 6 7 8 9 10 E. 4 20. Which of the following loop correctly prints the elements of the array? char[ ] arr = new chart[ ] {'k', 'i','C', 'i','t'} ;

do { A. Console.WriteLine((char) i); } while (int i = 0; i < arr; i++);

foreach (int i in arr) { B. Console.WriteLine((char) i); } for (int i = 0; i < arr; i++) { C. Console.WriteLine((char) i); } while (int i = 0; i < arr; i++) { D. Console.WriteLine((char) i); } do { E. Console.WriteLine((char) i); } until (int i = 0; i < arr; i++);

21. Which of the following statements is correct about the C#.NET code snippet given below? int i, j, id = 0; switch (id) { case i: Console.WriteLine("I am in Case i");

break; case j: Console.WriteLine("I am in Case j"); break; } The compiler will report case i and case j as errors since variables cannot be used in cases. Compiler will report an error since there is no default case in the switch case B. statement. C. The code snippet prints the result as "I am in Case i"". D.The code snippet prints the result as "I am in Case j". E. There is no error in the code snippet. A.

Operator

1. Which of the following are the correct ways to increment the value of variable a by 1? 1. ++a++; 2. a += 1; 3. a ++ 1;

4. a = a +1; 5. a = +1;

2. What will be the output of the C#.NET code snippet given below? byte b1 = 0xF7; byte b2 = 0xAB; byte temp; temp = (byte)(b1 & b2); Console.Write (temp + " "); temp = (byte)(b1^b2); Console.WriteLine(temp); A.163 92 B. 92 163 C. 192 63 D.0 1

3. Which of the following is NOT an Arithmetic operator in C#.NET? B. + A.** C. / D.% E. * 4. Which of the following are NOT Relational operators in C#.NET? 1. 2. 3. 4. 5. >= != Not <= <>=

5. Which of the following is NOT a Bitwise operator in C#.NET? A.& B. | C. << D.^ E. ~

6. Which of the following statements is correct about the C#.NET code snippet given

below? int d; d = Convert.ToInt32( !(30 < 20) ); A.A value 0 will be assigned to d. B. A value 1 will be assigned to d. C. A value -1 will be assigned to d. D.The code reports an error. E. The code snippet will work correctly if ! is replaced by Not. 7. Which of the following is the correct output for the C#.NET code snippet given below? Console.WriteLine(13 / 2 + " " + 13 % 2); A.6.5 1 B. 6.5 0 C. 6 0 D.6 1 6.5 6.5 E. 8. Which of the following statements are correct about the Bitwise & operator used in C#.NET? 1. 2. 3. 4. 5. The & operator can be used to Invert a bit. The & operator can be used to put ON a bit. The & operator can be used to put OFF a bit. The & operator can be used to check whether a bit is ON. The & operator can be used to check whether a bit is OFF.

9. Which of the following are Logical operators in C#.NET? 1. 2. 3. 4. 5. && || ! Xor %

10. Suppose n is a variable of the type Byte and we wish, to check whether its fourth bit (from right) is ON or OFF. Which of the following statements will do this correctly?

A.if ((n&16) == 16)

Console.WriteLine("Third bit is ON"); if ((n&8) == 8) B. Console.WriteLine("Third bit is ON"); if ((n ! 8) == 8) C. Console.WriteLine("Third bit is ON"); if ((n ^ 8) == 8) D. Console.WriteLine("Third bit is ON"); if ((n ~ 8) == 8) E. Console. WriteLine("Third bit is ON");

11. What will be the output of the C#.NET code snippet given below? int num = 1, z = 5; if (!(num <= 0)) Console.WriteLine( ++num + z++ + " " + ++z ); else Console.WriteLine( --num + z-- + " " + --z ); A.5 6 B. 6 5 C.6 6 D.7 7

12. Suppose n is a variable of the type Byte and we wish to put OFF its fourth bit (from right) without disturbing any other bits. Which of the following statements will do this correctly? A.n = n && HF7 B. n = n & 16 C.n = n & 0xF7 D.n = n & HexF7 E. n = n & 8

13. What will be the output of the C#.NET code snippet given below? byte b1 = 0xAB; byte b2 = 0x99; byte temp; temp = (byte)~b2;

Console.Write(temp + " "); temp = (byte)(b1 << b2); Console.Write (temp + " "); temp = (byte) (b2 >> 2); Console.WriteLine(temp); A.102 1 38 B. 108 0 32 C.102 0 38 D.1 0 1 14. Which of the following statements is correct about Bitwise | operator used in C#.NET? A.The | operator can be used to put OFF a bit. B. The | operator can be used to Invert a bit. C. The | operator can be used to check whether a bit is ON. D.The | operator can be used to check whether a bit is OFF. E. The | operator can be used to put ON a bit. 15. Which of the following is NOT an Assignment operator in C#.NET? B. /= A.\= C. *= D.+= E. %=

16. What will be the output of the C#.NET code snippet given below? int i, j = 1, k; for (i = 0; i < 5; i++) { k = j++ + ++j; Console.Write(k + " "); } A.8 4 16 12 20 B. 4 8 12 16 20 C. 4 8 16 32 64 D.2 4 6 8 10

17. What will be the output of the C#.NET code snippet given below? int a = 10, b = 20, c = 30; int res = a < b ? a < c ? c : a : b; Console.WriteLine(res);

A.10 B. 20 C.30 D.Compile Error / Syntax Error 18. Which of the following statements are correct about the following code snippet? int a = 10; int b = 20; bool c; c = !(a > b); 1. 2. 3. 4. 5. There is no error in the code snippet. An error will be reported since ! can work only with an int. A value 1 will be assigned to c. A value True will be assigned to c. A value False will be assigned to c.

19. Which of the following statements is correct about Bitwise ^ operator used in C#.NET? A.The ^ operator can be used to put ON a bit. B. The ^ operator can be used to put OFF a bit. C. The ^ operator can be used to Invert a bit. D.The ^ operator can be used to check whether a bit is ON. E. The ^ operator can be used to check whether a bit is OFF. 20. Which of the following statements are correct? 1. The conditional operator (?:) returns one of two values depending on the value of a Boolean expression. 2. The as operator in C#.NET is used to perform conversions between compatible reference types. 3. The &* operator is also used to declare pointer types and to dereference pointers. 4. The -> operator combines pointer dereferencing and member access. 5. In addition to being used to specify the order of operations in an expression, brackets [ ] are used to specify casts or type conversions.

Functions and Subroutins 1. Which of the following will be the correct output for the C#.NET program given

below? namespace IndiabixConsoleApplication { class SampleProgram { static void Main(string[] args) { int num = 1; funcv(num); Console.Write(num + ", "); funcr(ref num); Console.Write(num + ", "); } static void funcv(int num) { num = num + 10; Console.Write(num + ", "); } static void funcr (ref int num) { num = num + 10; Console.Write(num + ", "); } } } A.1, 1, 1, 1, B. 11, 1, 11, 11, C. 11, 11, 11, 11, D.11, 11, 21, 11, E. 11, 11, 21, 21,

2. What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class SampleProgram { static void Main(string[] args) { int[]arr = newint[]{ 1, 2, 3, 4, 5 }; fun(ref arr); } static void fun(ref int[] a) { for (int i = 0; i < a.Length; i++) {

a[i] = a[i] * 5; Console.Write(a[ i ] + " "); } } } } A.1 2 3 4 5 B. 6 7 8 9 10 C. 5 10 15 20 25 D.5 25 125 625 3125 E. 6 12 18 24 30

3. Which of the following statements are correct? 1. An argument passed to a ref parameter need not be initialized first. 2. Variables passed as out arguments need to be initialized prior to being passed. 3. Argument that uses params keyword must be the last argument of variable argument list of a method. 4. Pass by reference eliminates the overhead of copying large data items. 5. To use a ref parameter only the calling method must explicitly use the ref keyword.

4. A function returns a value, whereas a subroutine cannot return a value. B.False A.True

5. Which of the following statements are correct about functions and subroutines used in C#.NET? 1. A function cannot be called from a subroutine. 2. The ref keyword causes arguments to be passed by reference. 3. While using ref keyword any changes made to the parameter in the method will be reflected in that variable when control passes back to the calling method. 4. A subroutine cannot be called from a function. 5. Functions and subroutines can be called recursively.

6. Which of the following will be the correct output for the C#.NET program given below? namespace IndiabixConsoleApplication { class SampleProgram { static void Main(string[] args) { int a = 5; int s = 0, c = 0; Proc(a, ref s, ref c); Console.WriteLine(s + " " + c); } static void Proc(int x, ref int ss, ref int cc) { ss = x * x; cc = x * x * x; } } } A.0 0 B. 25 25 C. 125 125 D.25 125 E. None of the above

7. What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class SampleProgram { static void Main(string[ ] args) { int i = 10; double d = 34.340; fun(i); fun(d); } static void fun(double d) { Console.WriteLine(d + " ");

} } } A.10.000000 34.340000 B. 10 34 C. 10 34.340 D.10 34.34 Which of the following statements are correct? 1. 2. 3. 4. 5. C# allows a function to have arguments with default values. C# allows a function to have variable number of arguments. Omitting the return value type in method definition results into an exception. Redefining a method parameter in the method's body causes an exception. params is used to specify the syntax for a function with variable number of arguments.

If a procedure fun() is to receive an int, a Single & a double and it is to return a decimal then which of the following is the correct way of defining this procedure? fun(int i, Single j, double k) decimal A. { ... } static decimal fun(int i, Single j, double k) B. { ... } fun(int i, Single j, double k) { C. ... return decimal; } static decimal fun(int i, Single j, double k) decimal D. { ... } E. A procedure can never return a value.

10. If a function fun() is to receive an int, a Single & a double and it is to return a decimal then which of the following is the correct way of defining this function?

decimal static fun(int i, Single j, double k) { ... } decimal fun(int i, Single j, double k) B. { ... } static decimal fun(int i, Single j, double k) C. { ... } static decimal fun(int i, Single j, double k) decimal D. { ... } E. static fun(int i, Single j, double k) A.

{ ... return decimal; }

11. Which of the following statements are correct about functions used in C#.NET? 1. 2. 3. 4. 5. Function definitions cannot be nested. Functions can be called recursively. If we do not return a value from a function then a value -1 gets returned. To return the control from middle of a function exit function should be used. Function calls can be nested.

12. How many values is a function capable of returning? A.1 B. 0 C. Depends upon how many params arguments does it use. D.Any number of values. E. Depends upon how many ref arguments does it use.

13. What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class SampleProgram { static void Main(string[ ] args) { object[] o = new object[] {"1", 4.0, "India", 'B'}; fun (o); } static void fun (params object[] obj) { for (int i = 0; i < obj.Length-1; i++) Console.Write(obj[i] + " "); } } } A.1 4.0 India B B. 1 4.0 India

C.1 4 India D.1 India B

14. How many values is a subroutine capable of returning? A.Depends upon how many params arguments does it use. B. Any number of values. C. Depends upon how many ref arguments does it use. D.0 E. 1 15. Which of the following CANNOT occur multiple number of times in a program? A.namespace B. Entrypoint C. Class D.Function E. Subroutine 16. What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class SampleProgram { static void Main(string[ ] args) { int i; int res = fun(out i); Console.WriteLine(res); } static int fun (out int i) { int s = 1; i = 7; for(int j = 1; j <= i; j++) { s = s * j; } return s; } } }

A.1 C. 8 E. 5040

B. 7 D.720

17. If a function fun() is to sometimes receive an int and sometimes a double then which of the following is the correct way of defining this function? static void fun(object i) A. { ... } static void fun(int i) B. { ... } static void fun(double i, int j) C. { ... } static void fun(int i, double j) D. { ... } E. static void fun(int i, double j, ) 18. Which of the following statements are correct about subroutines used in C#.NET? 1. 2. 3. 4. 5. If we do not return a value from a subroutine then a value -1 gets returned. Subroutine definitions cannot be nested. Subroutine can be called recursively. To return the control from middle of a subroutine exit subroutine should be used. Subroutine calls can be nested.

19. A function can be used in an expression, whereas a subroutine cannot be. B.False A.True

20. Which of the following statements are correct about the C#.NET program given below? namespace IndiabixConsoleApplication { class SampleProgram { static void Main(string[ ] args) {

int a = 5; int s = 0, c = 0; s, c = fun(a); Console.WriteLine(s +" " + c) ; } static int fun(int x) { int ss, cc; ss = x * x; cc = x * x * x; return ss, cc; } } } 1. An error will be reported in the statement s, c = fun(a); since multiple values returned from a function cannot be collected in this manner. 2. It will output 25 125. 3. It will output 25 0. 4. It will output 0 125. 5. An error will be reported in the statement return ss, cc; since a function cannot return multiple values. 21. What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class SampleProgram { static void Main(string[ ] args) { int i = 5; int j; fun1(ref i); fun2(out j); Console.WriteLine(i + ", " + j); } static void funl(ref int x) { x = x * x; } static void fun2(out int x) { x = 6; x = x * x; } }

} A.5, 6 B. 5, 36 C. 25, 36 D.25, 0 E. 5, 0

Inheritance 1. Which of the following can be facilitated by the Inheritance mechanism? 1. 2. 3. 4. 5. Use the existing functionality of base class. Overrride the existing functionality of base class. Implement new functionality in the derived class. Implement polymorphic behaviour. Implement containership.

2. Which of the following statements should be added to the subroutine fun( ) if the C#.NET code snippet given below is to output 9 13? class BaseClass { protected int i = 13; } class Derived: BaseClass { int i = 9; public void fun() { // [*** Add statement here ***] } }

A.Console.WriteLine(base.i + " " + i); B. Console.WriteLine(i + " " + base.i); C. Console.WriteLine(mybase.i + " " + i); D.Console.WriteLine(i + " " + mybase.i); E. Console.WriteLine(i + " " + this.i);

3. Which of the following statements are correct about the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class index { protected int count; public index() { count = 0; } } class index1: index { public void increment() { count = count +1; } } class MyProgram { static void Main(string[] args) { index1 i = new index1(); i.increment(); } } } 1. count should be declared as public if it is to become available in the inheritance chain. 2. count should be declared as protected if it is to become available in the inheritance chain. 3. While constructing an object referred to by i firstly constructor of index class will be called followed by constructor of index1 class. 4. Constructor of index class does not get inherited in index1 class. 5. count should be declared as Friend if it is to become available in the inheritance chain.

4. What will be the size of the object created by the following C#.NET code snippet? namespace IndiabixConsoleApplication { class Baseclass { private int i; protected int j; public int k; } class Derived: Baseclass { private int x; protected int y; public int z; } class MyProgram { static void Main (string[ ] args) { Derived d = new Derived(); } } } A.24 bytes B. 12 bytes C. 20 bytes D.10 bytes E. 16 bytes

5. 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.base.fun(); B. A::fun(); C. fun(); D.mybase.fun(); E. A.fun();

6. What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class Baseclass { public void fun() { Console.Write("Base class" + " "); } } class Derived1: Baseclass { new void fun() { Console.Write("Derived1 class" + " "); } } class Derived2: Derived1 { new void fun() { Console.Write("Derived2 class" + " "); } }

class Program { public static void Main(string[ ] args) { Derived2 d = new Derived2(); d.fun(); } } } A.Base class B. Derived1 class C. Derived2 class D.Base class Derived1 class E. Base class Derived1 class Derived2 class

7. Which of the following should be used to implement a 'Has a' relationship between two entities? A.Polymorphism B. Templates D.Encapsulation C.Containership E. Inheritance

8. Which of the following is correct about the C#.NET snippet given below? namespace IndiabixConsoleApplication { class Baseclass { public void fun() { Console.WriteLine("Hi" + " "); } public void fun(int i) { Console.Write("Hello" + " "); } } class Derived: Baseclass { public void fun() { Console.Write("Bye" + " "); } } class MyProgram

{ static void Main(string[ ] args) { Derived d; d = new Derived(); d.fun(); d.fun(77); } } } A.The program gives the output as: Hi Hello Bye B. The program gives the output as: Bye Hello C. The program gives the output as: Hi Bye Hello D.Error in the program 9. In an inheritance chain which of the following members of base class are accessible to the derived class members? 1. 2. 3. 4. 5. static protected private shared public

Which of the following are reuse mechanisms available in C#.NET? 1. 2. 3. 4. 5. Inheritance Encapsulation Templates Containership Polymorphism

Which of the following should be used to implement a 'Like a' or a 'Kind of' relationship between two entities? A.Polymorphism B. Containership C. Templates D.Encapsulation E. Inheritance

12. How can you prevent inheritance from a class in C#.NET ? A.Declare the class as shadows.

B. Declare the class as overloads. C. Declare the class as sealed. D.Declare the class as suppress. E. Declare the class as override.

13. Which of the following statements are correct about Inheritance in C#.NET? 1. 2. 3. 4. 5. A derived class object contains all the base class data. Inheritance cannot suppress the base class functionality. A derived class may not be able to access all the base class data. Inheritance cannot extend the base class functionality. In inheritance chain construction of object happens from base towards derived.

14. Assume class B is inherited from class A. Which of the following statements is correct about construction of an object of class B? While creating the object firstly the constructor of class B will be called followed A. by constructor of class A. While creating the object firstly the constructor of class A will be called B. followed by constructor of class B. C. The constructor of only class B will be called. D.The constructor of only class A will be called. The order of calling constructors depends upon whether constructors in class A and E. class B are private or public.

15. Which of the following statements is correct about the C#.NET program given below?

namespace IndiabixConsoleApplication { class Baseclass { int i; public Baseclass(int ii) { i = ii; Console.Write("Base "); } } class Derived : Baseclass { public Derived(int ii) : base(ii) { Console.Write("Derived "); } } class MyProgram { static void Main(string[ ] args) { Derived d = new Derived(10); } } } The program will work correctly only if we implement zero-argument constructors A. in Baseclass as well as Derived class. B. The program will output: Derived Base C. The program will report an error in the statement base(ii). D.The program will work correctly if we replace base(ii) with base.Baseclass(ii). E. The program will output: Base Derived

Properties

1. A property can be declared inside a class, struct, Interface. B.False A.True

2. Which of the following statements is correct about properties used in C#.NET? A.A property can simultaneously be read only or write only. B. A property can be either read only or write only. C. A write only property will have only get accessor. D.A write only property will always return a value.

3. A Student class has a property called rollNo and stu is a reference to a Student object and we want the statement stu.RollNo = 28 to fail. Which of the following options will ensure this functionality? A.Declare rollNo property with both get and set accessors. B. Declare rollNo property with only set accessor. C. Declare rollNo property with get, set and normal accessors. D.Declare rollNo property with only get accessor. E. None of the above

4. If a class Student has an indexer, then which of the following is the correct way to declare this indexer to make the C#.NET code snippet given below work successfully? Student s = new Student(); s[1, 2] = 35; class Student { int[ ] a = new int[5, 5]; public property WriteOnly int this[int i, int j] { set A. { a[i, j] = value; } } } B. class Student

{ int[ , ] a = new int[5, 5]; public int property WriteOnly { set { a[i, j] = value; } } } class Student { int[ , ] a = new int[5, 5]; public int this[int i, int j] { C. set { a[i, j] = value; } } } class Student { int[ , ] a = new int[5, 5]; int i, j; public int this { D. set { a[i, j] = value; } } } 5. Which of the following statements are correct? 1. The signature of an indexer consists of the number and types of its formal parameters. 2. Indexers are similar to properties except that their accessors take parameters. 3. Accessors of interface indexers use modifiers. 4. The type of an indexer and the type of its parameters must be at least as accessible as the indexer itself. 5. An interface accessor contains a body.

6. If Sample class has a Length property with get and set accessors then which of the following statements will work correctly? Sample.Length = 20; Sample m = new Sample(); m.Length = 10; Console.WriteLine(Sample.Length); Sample m = new Sample(); int len; len = m.Length; Sample m = new Sample(); m.Length = m.Length + 20;

7. Which of the following is the correct way to implement a write only property Length in a Sample class? class Sample { public int Length { set A. { Length = value; } } } class Sample { int len; public int Length { B. get { return len; } set {

len = value; } } } class Sample { int len; public int Length { C. WriteOnly set { len = value; } } } class Sample { int len; public int Length { D. set { len = value; } } } 9. If a Student class has an indexed property which is used to store or retrieve values to/from an array of 5 integers, then which of the following are the correct ways to use this indexed property? Student[3] = 34; Student s = new Student(); s[3] = 34; Student s = new Student(); Console.WriteLine(s[3]); Console.WriteLine(Student[3]); Student.this s = new Student.this(); s[3] = 34;

10. If Sample class has a Length property with set accessor then which of the following statements will work correctly? Sample m = new Sample(); int l; A. l = m.Length; B. Sample m = new Sample(); m.Length = m.Length + 20;

C. Sample.Length = 20;

D.Console.WriteLine (Sample.Length);

E. Sample m = new Sample(); m.Length = 10;

11. If Sample class has a Length property with get accessor then which of the following statements will work correctly? A. Sample m = new Sample(); m.Length = 10;

B.

Sample m = new Sample(); m.Length = m.Length + 20;

Sample m = new Sample(); C.int l; l = m.Length;

D.Sample.Length = 20; E. Console.WriteLine(Sample.Length);

12. An Account class has a property called accountNo and acc is a reference to a bank object and we want the C#.NET code snippet given below to work. Which of the following options will ensure this functionality? acc.accountNo = 10;

Console.WriteLine(acc.accountNo); A.Declare accountNo property with both get and set accessors. B. Declare accountNo property with only get accessor. C. Declare accountNo property with get, set and normal accessors. D.Declare accountNo property with only set accessor. E. None of the above 13. Suppose a Student class has an indexed property. This property is used to set or retrieve values to/from an array of 5 integers called scores[]. We want the property to report "Invalid Index" message if the user attempts to exceed the bounds of the array. Which of the following is the correct way to implement this property? class Student { int[] scores = new int[5] {3, 2, 4,1, 5}; public int this[ int index ] { set { A. if (index < 5) scores[index] = value; else Console.WriteLine("Invalid Index"); } } } class Student { int[] scores = new int[5] {3, 2, 4, 1, 5}; public int this[ int index ] { get { if (index < 5) return scores[ index ]; else B. { Console.WriteLine("Invalid Index"); return 0; } } set { if (index < 5) scores[ index ] = value; else Console.WriteLine("Invalid Index");

} } } class Student { int[] scores = new int[5] {3, 2, 4, 1, 5}; public int this[ int index ] { get { if (index < 5) C. return scores[ index ]; else { Console.WriteLine("Invalid Index"); return 0; } } } } class Student { int[] scores = new int[5] {3, 2, 4, 1, 5}; public int this[ int index ] { get { if (index < 5) scores[ index ] = value; else { Console.WriteLine("Invalid Index"); } D. } set { if (index < 5) return scores[ index ]; else { Console.WriteLine("Invalid Index"); return 0; } } } }

14. Which of the following statements is correct about properties used in C#.NET? A.Every property must have a set accessor and a get accessor. B. Properties cannot be overloaded. C. Properties of a class are actually methods that work like data members. D.A property has to be either read only or a write only.

15. Which of the following is the correct way to implement a read only property Length in a Sample class?

class Sample { int len; public int Length { get A. { return len; } } } class Sample { public int Length { get B. { return Length; } } } class Sample { int len; public int Length { C. get { return len; } set {

len = value; } } } class Sample { int len; public int Length { D. Readonly get { return len; } } } 16. Which of the folowing does an indexer allow to index in the same way as an array? 1. 2. 3. 4. 5. A class A property A struct A function An interface

17. An Employee class has a property called age and emp is reference to a Employee object and we want the statement Console.WriteLine(emp.age) to fail. Which of the following options will ensure this functionality? A.Declare age property with only get accessor. B. Declare age property with only set accessor. C. Declare age property with both get and set accessors. D.Declare age property with get, set and normal accessors. E. None of the above

Exception Handling 1. Which of the following is NOT a .NET Exception class? A.Exception B. StackMemoryException C. DivideByZeroException D.OutOfMemoryException E. InvalidOperationException

2. Which of the following statements is correct about an Exception? A.It occurs during compilation. B. It occurs during linking. C. It occurs at run-time. D.It occurs during Just-In-Time compilation. E. It occurs during loading of the program.

3. In C#.NET if we do not catch the exception thrown at runtime then which of the following will catch it? A.Compiler B. CLR C. Linker D.Loader E. Operating system

4. 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"); } } } A.Value 44 will get assigned to a[6] . B. It will output: Index out of bounds C. It will output: Remaining program D.It will not produce any output. E. It will output: Index out of bounds Remaining program 5. Which of the following statements are correct about exception handling in C#.NET? 1. If an exception occurs then the program terminates abruptly without getting any chance to recover from the exception. 2. No matter whether an exception occurs or not, the statements in the finally clause (if present) will get executed. 3. A program can contain multiple finally clauses. 4. A finally clause is written outside the try block. 5. finally clause is used to perform clean up operations like closing the network/database connections.

6. Which of the following statements are correct about exception handling in C#.NET? 1. 2. 3. 4. 5. If our program does not catch an exception then the .NET CLR catches it. It is possible to create user-defined exceptions. All types of exceptions can be caught using the Exception class. CLRExceptions is the base class for all exception classes. For every try block there must be a corresponding finally block.

7. Which of the following statements are correct about the exception reported below? Unhandled Exception: System.lndexOutOfRangeException: Index was outside the bounds of the array: at IndiabixConsoleApplication.MyProgram.SetVal(Int32 index, Int32 val) in D:\Sample\IndiabixConsoleApplication\MyProgram.cs:line 26 at IndiabixConsoleApplication.MyProgram.Main(String[] args) in D:\Sample\IndiabixConsoleApplication\MyProgram.cs:line 20 1. The CLR failed to handle the exception. 2. The class MyProgram belongs to the namespace MyProgram.

3. The function SetVal() was called from Main() in line number 20. 4. The exception occurred in line number 26 in the function SetVal() 5. The runtime exception occurred in the project IndiabixConsoleApplication.

8. Which of the following is the Object Oriented way of handling run-time errors? A.OnError B. HERESULT C.Exceptions D.Error codes E. Setjump and Longjump

9. Which of the following statements is correct about the C#.NET program given below if a value "6" is input to it? using System; namespace IndiabixConsoleApplication { class MyProgram { static void Main(string[] args) { int index; int val = 44; int[] a = new int[5]; try { Console.Write("Enter a number:"); index = Convert.Tolnt32(Console.ReadLine()); a[index] = val; } catch(FormatException e) { Console.Write("Bad Format"); } catch(IndexOutOfRangeException e) { Console.Write("Index out of bounds"); } Console.Write("Remaining program"); } } } A.It will output: Index out of bounds Remaining program B. It will output: Bad Format Remaining program

C. It will output: Bad Format D.It will output: Remaining program E. It will output: Index out of bounds

10. Which of the following statements are correct about the exception reported below? Unhandled Exception: System.lndexOutOfRangeException: Index was outside the bounds of the array. at IndiabixConsoleApplication.Program.Main(String[] args) in D:\ConsoleApplication\Program.cs:line 14 1. The program did not handle an exception called IndexOutOfRangeException. 2. The program execution continued after the exception occurred. 3. The exception occurred in line number 14. 4. In line number 14, the program attempted to access an array element which was beyond the bounds of the array. 5. The CLR could not handle the exception.

11. Which of the following statements are correct about exception handling in C#.NET? 1. 2. 3. 4. 5. try blocks cannot be nested. In one function, there can be only one try block. An exception must be caught in the same function in which it is thrown. All values set up in the exception object are available in the catch block. While throwing a user-defined exception multiple values can be set in the exception, object.

12. Exceptions can be thrown even from a constructor, whereas error codes cannot be returned from a constructor. B.False A.True 13. Which of the following statements is correct about the C#.NET program given below if a value "6" is input to it? using System;

namespace IndiabixConsoleApplication { class MyProgram { static void Main (string[] args) { int index; int val = 66; int[] a = new int[5]; try { Consote.Write("Enter a number: "); index = Convert.ToInt32(Console.ReadLine()); a[index] = val; } catch(Exception e) { Console.Write("Exception occurred "); } Console.Write("Remaining program "); } } } A.It will output: Exception occurred B. It will output: Remaining program C.It will output: Exception occurred Remaining program D.It will output: Remaining program Exception occurred E. The value 66 will get assigned to a[6] .

14. 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 val = 55; int[] a = new int[5]; try { Console.Write("Enter a number: ");

index = Convert.ToInt32(Console.ReadLine()); a[index] = val; } catch(FormatException e) { Console.Write("Bad Format "); } catch(IndexOutOfRangeException e) { Console.Write("Index out of bounds "); } Console.Write("Remaining program "); } } } A.It will output: Bad Format B. It will output: Remaining program C. It will output: Index out of bounds D.It will output: Bad Format Remaining program E. It will output: Index out of bounds Remaining program

15. All code inside finally block is guaranteed to execute irrespective of whether an exception occurs in the protected block or not. B.False A.True 16. Which of the following is NOT an Exception? A.StackOverflow B. Division By Zero C. Insufficient Memory D.Incorrect Arithmetic Expression E. Arithmetic overflow or underflow 17. 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"); } } } A.It will output: Exception occurred B. It will output: Remaining program C. It will output: Remaining program Exception occurred D.It will output: Exception occurred Remaining program E. The value 88 will get assigned to a[0] .

18. It is compulsory for all classes whose objects can be thrown with throw statement to be derived from System.Exception class. A.True B.False

Structure 1. The space required for structure variables is allocated on stack. B.False A.True

2. Creating empty structures is allowed in C#.NET. A.True B.False 3. Which of the following will be the correct output for the C#.NET program given below? namespace IndiabixConsoleApplication { struct Sample { public int i; } class MyProgram

{ static void Main() { Sample x = new Sample(); x.i = 10; fun(x); Console.Write(x.i + " "); } static void fun(Sample y) { y.i = 20; Console.Write(y.i + " "); } } } A.10 20 B. 10 10 C.20 10 D.20 20 E. None of the above

4. Which of the following is the correct way of setting values into the structure variable e defined below? struct Emp { public String name; public int age; public Single sal; } Emp e = new Emp();

e.name = "Amol"; A.e.age = 25; e.sal = 5500;

With e { B. .name = "Amol"; .age = 25; .sal = 5500; } C. With emp e

{ .name = "Amol"; .age = 25; .sal = 5500; } e -> name = "Amol"; D.e -> age = 25; e -> sal = 5500; name = "Amol"; E. age = 25; sal = 5500;

5. Which of the following is the correct way to define a variable of the type struct Emp declared below? struct Emp { private String name; private int age; private Single sal; }

1. 2. 3. 4. 5.

Emp e(); e = new Emp(); Emp e = new Emp; Emp e; e = new Emp; Emp e = new Emp(); Emp e;

6. 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();

A.ss will be created on the heap. B. Trial object referred by z will be created on the stack. C. z will be created on the heap. D.Both ss and z will be created on the heap. E. ss will be created on the stack.

7. How many bytes will the structure variable samp occupy in memory if it is defined as shown below? class Trial { int i; Decimal d; } struct Sample { private int x; private Single y; private Trial z; } Sample samp = new Sample(); A.20 bytes B. 12 bytes C. 8 bytes D.16 bytes E. 24 bytes

8. Which of the following will be the correct result of the statement b = a in the C#.NET code snippet given below? struct Address { private int plotno; private String city; } Address a = new Address(); Address b; b = a; A.All elements of a will get copied into corresponding elements of b. B. Address stored in a will get copied into b. C. Once assignment is over a will get garbage collected.

D.Once assignment is over a will go out of scope, hence will die. E. Address of the first element of a will get copied into b. 9. Which of the following statements are correct? 1. 2. 3. 4. 5. A struct can contain properties. A struct can contain constructors. A struct can contain protected data members. A struct cannot contain methods. A struct cannot contain constants.

10. C#.NET structures are always value types. A.True

B.False

11. When would a structure variable get destroyed? A.When no reference refers to it, it will get garbage collected. B. Depends upon whether it is created using new or without using new. C. When it goes out of scope. D.Depends upon the Project Settings made in Visual Studio.NET. E. Depends upon whether we free it's memory using free() or delete().

12. Which of the following statements is correct about the C#.NET code snippet given below? struct Book { private String name; private int noofpages; private Single price; } Book b = new Book(); A.The structure variable b will be created on the heap. B. We can add a zero-argument constructor to the above structure. C. When the program terminates, variable b will get garbage collected. D.The structure variable b will be created on the stack.

E. We can inherit a new structure from struct Book.

13. Which of the following will be the correct output for the C#.NET program given below? namespace IndiabixConsoleApplication { struct Sample { public int i; } class MyProgram { static void Main(string[] args) { Sample x = new Sample(); x.i = 10; fun(ref x); Console.Write(x.i + " "); } public static void fun(ref Sample y) { y.i = 20; Console.Write(y.i + " "); } } } A.20 10 B. 10 20 C. 10 10 D.20 20 E. None of the above

14. Which of the following statements is correct? A.A struct never declares a default constructor. All value types in C# inherently derive from ValueType, which inherits from B. Object. C. A struct never declares a default destructor. D.In C#, classes and structs are semantically same.

15. Which of the following statements are correct about the structure declaration given

below? struct Book { private String name; protected int totalpages; public Single price; public void Showdata() { Console.WriteLine(name + " " + totalpages + " " + price); } Book() { name = " "; totalpages = 0; price = 0.0f; } } Book b = new Book(); 1. 2. 3. 4. 5. We cannot declare the access modifier of totalpages as protected. We cannot declare the access modifier of name as private. We cannot define a zero-argument constructor inside a structure. We cannot declare the access modifier of price as public. We can define a Showdata() method inside a structure.

16. Which of the following are true about classes and struct? 1. A class is a reference type, whereas a struct is a value type. 2. Objects are created using new, whereas structure variables can be created either using new or without using new. 3. A structure variable will always be created slower than an object. 4. A structure variable will die when it goes out of scope. 5. An object will die when it goes out of scope.

17. Which of the following will be the correct output for the program given below? namespace IndiabixConsoleApplication { struct Sample { public int i;

} class MyProgram { static void Main(string[] args) { Sample x = new Sample(); Sample y; x.i = 9; y = x; y.i = 5; Console.WriteLine(x.i + " " + y.i); } } } A.9 9 B. 9 5 C. 5 5 D.5 9 E. None of the above

18. Which of the following statements are correct about Structures used in C#.NET? 1. A Structure can be declared within a procedure. 2. Structs can implement an interface but they cannot inherit from another struct. 3. struct members cannot be declared as protected. 4. A Structure can be empty. 5. It is an error to initialize an instance field in a struct. A.1, 2, 4 B. 2, 3, 5 C. 2, 4 D.1, 3

Namespaces

1. If a namespace is present in a library then which of the following is the correct way to

use the elements of the namespace? Add Reference of the namespace. A. Use the elements of the namespace. Add Reference of the namespace. B. Import the namespace. Use the elements of the namespace. Import the namespace. C. Use the elements of the namespace. Copy the library in the same directory as the project that is trying to use it. D. Use the elements of the namespace. Install the namespace in Global Assembly Cache. E. Use the elements of the namespace. 2. Which of the following is NOT a namespace in the .NET Framework Class Library? A.System.Process B. System.Security C. System.Threading D.System.Drawing E. System.Xml

3. Which of the following statments are the correct way to call the method Issue() defined in the code snippet given below? namespace College { namespace Lib { class Book { public void Issue() { // Implementation code } } class Journal { public void Issue() { // Implementation code } } } } College.Lib.Book b = new College.Lib.Book();

b.Issue(); Book b = new Book(); b.Issue(); using College.Lib; Book b = new Book(); b.Issue(); using College; Lib.Book b = new Lib.Book(); b.Issue(); using College.Lib.Book; Book b = new Book(); b.Issue(); 4. Which of the following statements is correct about a namespace in C#.NET? A.Namespaces help us to control the visibility of the elements present in it. B. A namespace can contain a class but not another namespace. C. If not mentioned, then the name 'root' gets assigned to the namespace. D.It is necessary to use the using statement to be able to use an element of a namespace. We need to organise the classes declared in Framework Class Library into different E. namespaces.

5. Which of the following is absolutely neccessary to use a class Point present in namespace Graph stored in library? A.Use fully qualified name of the Point class. B. Use using statement before using the Point class. C.Add Reference of the library before using the Point class. D.Use using statement before using the Point class. E. Copy the library into the current project directory before using the Point class.

6. If a class called Point is present in namespace n1 as well as in namespace n2, then which of the following is the correct way to use the Point class? namespace IndiabixConsoleApplication { class MyProgram { A. static void Main(string[] args) { import n1; Point x = new Point(); x.fun();

import n2; Point y = new Point(); y.fun(); } } } import n1; import n2; namespace IndiabixConsoleApplication { class MyProgram { static void Main(string[] args) B. { n1.Point x = new n1.Point(); x.fun(); n2.Point y = new n2.Point(); y.fun(); } } } namespace IndiabixConsoleApplication { class MyProgram { static void Main(string[] args) { using n1; C. Point x = new Point(); x.fun(); using n2; Point y = new Point(); y.fun(); } } } using n1; using n2; namespace IndiabixConsoleApplication { class MyProgram D. { static void Main(string[] args) { n1.Point x = new n1.Point(); x.fun();

n2.Point y = new n2.Point(); y.fun(); } } }

7. Which of the followings are NOT a .NET namespace? 1. 2. 3. 4. 5. System.Web System.Process System.Data System.Drawing2D System.Drawing3D

8. Which of the following statements is correct about namespaces in C#.NET? A.Namespaces can be nested only up to level 5. B. A namespace cannot be nested. C. There is no limit on the number of levels while nesting namespaces. If namespaces are nested, then it is necessary to use using statement while using the D. elements of the inner namespace. Nesting of namespaces is permitted, provided all the inner namespaces are declared E. in the same file.

9. Which of the following is correct way to rewrite the C#.NET code snippet given below? using Microsoft.VisualBasic; using System.Windows.Forms; MessageBox.Show("Wait for a" + ControlChars.CrLf + "miracle"); using System.Windows.Forms; A.using CtrlChars = Microsoft.VisualBasic.ControlChars; MessageBox.Show("Wait for a" + CrLf + "miracle"); using Microsoft.VisualBasic; using System.Windows.Forms; B. CtrlChars = ControlChars; MessageBox.Show("Wait for a" + CtrlChars.CrLf + "miracle"); C. using Microsoft.VisualBasic;

using System.Windows.Forms; CtrlChars = ControlChars; MessageBox.Show ("Wait for a" + CrLf + "miracle"); using System.Windows.Forms; D.using CtrlChars = Microsoft.VisualBasic.ControlChars; MessageBox.Show("Wait for a" + CtrlChars.CrLf + "miracle");

10. Which of the following statements is correct about the using statement used in C#.NET? A.using statement can be placed anywhere in the C#.NET source code file. B. It is permitted to define a member at namespace level as a using alias. C.A C#.NET source code file can contain any number of using statement. By using using statement it is possible to create an alias for the namespace but not D. for the namespace element. By using using statement it is possible to create an alias for the namespace element E. but not for the namespace.

11. Which of the following statements are correct about a namespace used in C#.NET? 1. Classes must belong to a namespace, whereas structures need not. 2. Every class, struct, enum, delegate and interlace has to belong to some or the other namespace. 3. All elements of the namespace have to belong to one file. 4. If not mentioned, a namespace takes the name of the current project. 5. The namespace should be imported to be able to use the elements in it.

12. Which of the following CANNOT belong to a C#.NET Namespace? A.class B. struct C. enum D.Data E. interface 13. Which of the following statements is correct about a namespace used in C#.NET? A.Nested namespaces are not allowed. B. Importing outer namespace imports inner namespace. C.Nested namespaces are allowed. D.If nested, the namespaces cannot be split across files.

14. Which of the following C#.NET code snippets will correctly print "Hello C#.NET"? A.import System;

namespace IndiabixConsoleApplication { class MyProgram { static void Main(string[] args) { Console.WriteLine("Hello C#.NET"); } } } using System; namespace IndiabixConsoleApplication { class MyProgram { B. static void Main(string[ ] args) { WriteLine("Hello C#.NET"); } } } using System.Console; namespace IndiabixConsoleApplication { class MyProgram { C. static void Main (string[ ] args) { WriteLine("Hello C#.NET"); } } } using System; namespace IndiabixConsoleApplication { class MyProgram { D. static void Main(string[] args) { Console.WriteLine("Hello C#.NET"); } } }

15. If ListBox is class present in System.Windows.Forms namespace, then which of the

following statements are the correct way to create an object of ListBox Class? using System.Windows.Forms; ListBox lb = new ListBox(); using LBControl = System.Windows.Forms; LBControl lb = new LBControl(); System.Windows.Forms.ListBox lb = new System.Windows.Forms.ListBox(); using LBControl lb = new System.Windows.Forms.ListBox; using LBControl = System.Windows.Forms.ListBox; LBControl lb = new LBControl();

Interfaces 1. Which of the following statements is correct about the C#.NET code snippet given below? interface IMyInterface { void fun1(); int fun2(); } class MyClass: IMyInterface { void fun1() {} int IMyInterface.fun2() {} } A.A function cannot be declared inside an interface. B. A subroutine cannot be declared inside an interface. C. A Method Table will not be created for class MyClass. D.MyClass is an abstract class. E. The definition of fun1() in class MyClass should be void IMyInterface.fun1().

2. Which of the following can be declared in an interface? 1. 2. 3. 4. 5. Properties Methods Enumerations Events Structures

3. A class implements two interfaces each containing three methods. The class contains no instance data. Which of the following correctly indicate the size of the object created from this class? A.12 bytes B. 24 bytes C. 0 byte D.8 bytes E. 16 bytes

4. Which of the following statements is correct about an interface used in C#.NET? A.One class can implement only one interface. In a program if one class implements an interface then no other class in the same B. program can implement this interface. C. From two base interfaces a new interface cannot be inherited. D.Properties can be declared inside an interface. E. Interfaces cannot be inherited.

5. Which of the following statements is correct about Interfaces used in C#.NET? A.All interfaces are derived from an Object class. B. Interfaces can be inherited. C. All interfaces are derived from an Object interface. D.Interfaces can contain only method declaration. E. Interfaces can contain static data and methods. 6. Which of the following statements is correct about an interface used in C#.NET? A.If a class implements an interface partially, then it becomes an abstract class. B. A class cannot implement an interface partially. C. An interface can contain static methods. D.An interface can contain static data. E. Multiple interface inheritance is not allowed. 7. Which of the following statements is correct about an interface?

A.One interface can be implemented in another interface. B. An interface can be implemented by multiple classes in the same program. A class that implements an interface can explicitly implement members of that C. interface. D.The functions declared in an interface have a body. 8. Which of the following statements are correct about an interface in C#.NET? 1. A class can implement multiple interfaces. 2. Structures cannot inherit a class but can implement an interface. 3. In C#.NET, : is used to signify that a class member implements a specific interface. 4. An interface can implement multiple classes. 5. The static attribute can be used with a method that implements an interface declaration.

9. Which of the following is the correct implementation of the interface given below? interface IMyInterface { double MyFun(Single i); } class MyClass { double MyFun(Single i) as IMyInterface.MyFun A. { // Some code } } class MyClass { MyFun (Single i) As Double B. { // Some code } } class MyClass: implements IMyInterface { double fun(Single si) implements IMyInterface.MyFun() C. { //Some code }

} class MyClass: IMyInterface { double IMyInterface.MyFun(Single i) D. { // Some code } } 10. Which of the following statements is correct? When a class inherits an interface it inherits member definitions as well as its A. implementations. B. An interface cannot contain the signature of an indexer. C. Interfaces members are automatically public. To implement an interface member, the corresponding member in the class must be D. public as well as static.

11. Which of the following statements are correct about an interface used in C#.NET? 1. 2. 3. 4. 5. An interface can contain properties, methods and events. The keyword must implement forces implementation of an interface. Interfaces can be overloaded. Interfaces can be implemented by a class or a struct. Enhanced implementations of an interface can be developed without breaking existing code.

12. Which of the following can implement an interface? 1. 2. 3. 4. 5. Data Class Enum Structure Namespace

13. Which of the following statements is correct about the C#.NET code snippet given below? interface IMyInterface { void fun1(); void fun2(); } class MyClass: IMyInterface { private int i; void IMyInterface.fun1() { // Some code } } A.Class MyClass is an abstract class. B. Class MyClass cannot contain instance data. C. Class MyClass fully implements the interface IMyInterface. D.Interface IMyInterface should be inherited from the Object class. The compiler will report an error since the interface IMyInterface is only partially E. implemented.

14. Which of the following statements is correct about the C#.NET code snippet given below? interface IPerson { String FirstName { get; set; } String LastName { get; set; } void Print(); void Stock(); int Fun();

} A.Properties cannot be declared inside an interface. B. This is a perfectly workable interface. C. The properties in the interface must have a body. D.Subroutine in the interface must have a body. E. Functions cannot be declared inside an interface.

15. Which of the following is the correct way to implement the interface given below? interface IPerson { String FirstName { get; set; } } class Employee : IPerson { private String str; public String FirstName { get { A. return str; } set { str = value; } } } class Employee { private String str; public String IPerson.FirstName { get B. { return str; } set { str = value;

} } } class Employee : implements IPerson { private String str; public String FirstName { get { C. return str; } set { str = value; } } } D.None of the above

Datatypes 1 Which of the following statements are correct about data types? 1. If the integer literal exceeds the range of byte, a compilation error will occur. 2. We cannot implicitly convert non-literal numeric types of larger storage size to byte. 3. Byte cannot be implicitly converted to float.

4. A char can be implicitly converted to only int data type. 5. We can cast the integral character codes.

2. Which of the following is an 8-byte Integer? A.Char B. Long C. Short D.Byte E. Integer 3. Which of the following is NOT an Integer? A.Char B. Byte C. Integer D.Short E. Long 4. Which of the following statements is correct? A.Information is never lost during narrowing conversions. B. The CInteger() function can be used to convert a Single to an Integer. C.Widening conversions take place automatically. D.Assigning an Integer to an Object type is known as Unboxing. E. 3.14 can be treated as Decimal by using it in the form 3.14F.

5. Which of the following are value types? 1. 2. 3. 4. 5. Integer Array Single String Long

6. Which of the following does not store a sign? A.Short B. Integer C. Long D.Byte E. Single

7. What is the size of a Decimal?

A.4 byte B. 8 byte C.16 byte D.32 byte

8. 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)); B. 1.0 A.0.1 C. 1.1 D.11

9. Which of the following statements is correct about the C#.NET code snippet given below? short s1 = 20; short s2 = 400; int a; a = s1 * s2; A.A value 8000 will be assigned to a. B. A negative value will be assigned to a. During arithmetic if the result exceeds the high or low value of the range the value C. wraps around till the other side of the range. D.An error is reported as widening conversion cannot takes place. An overflow error will be reported since the result of the multiplication exceeds the E. range of a Short Integer.

10. Which of the following is the correct size of a Decimal datatype? A.8 Bytes B. 4 Bytes C. 10 Bytes D.16 Bytes E. None of the above.

11. Which of the following statements are correct? 1. We can assign values of any type to variables of type object. 2. When a variable of a value type is converted to object, it is said to be unboxed. 3. When a variable of type object is converted to a value type, it is said to be boxed. 4. Boolean variable cannot have a value of null. 5. When a value type is boxed, an entirely new object must be allocated and constructed.

12. Which of the following is the correct ways to set a value 3.14 in a variable pi such that it cannot be modified? A.float pi = 3.14F; B. #define pi 3.14F; C.const float pi = 3.14F; D.const float pi; pi = 3.14F; E. pi = 3.14F;

13. Which of the following statements are correct about data types? 1. Each value type has an implicit default constructor that initializes the default value of that type. 2. It is possible for a value type to contain the null value. 3. All value types are derived implicitly from System.ValueType class. 4. It is not essential that local variables in C# must be initialized before being used. 5. Variables of reference types referred to as objects and store references to the actual data.

14. Which of the following are the correct way to initialise the variables i and j to a value 10 each? 1. 2. 3. 4. 5. 6. int i = 10; int j = 10; int i, j; i = 10 : j = 10; int i = 10, j = 10; int i, j = 10; int i = j = 10;

15. Which of the following statement correctly assigns a value 33 to a variable c? byte a = 11, b = 22, c; A.c = (byte) (a + b); B. c = (byte) a + (byte) b; C. c = (int) a + (int) b; D.c = (int)(a + b); E. c = a + b; 16. Which of the following statements are correct about datatypes in C#.NET? 1. 2. 3. 4. Every datatype is either a value type or a reference type. Value types are always created on the heap. Reference types are always created on the stack. Mapping of every value type to a type in Common Type System facilitates Interoperability in C#.NET. 5. Every reference type gets mapped to a type in Common Type System.

17. Which of the following is the correct default value of a Boolean type? A.0 B. 1 C. True D.False E. -1

Exception Handling 1. Which of the following is NOT a .NET Exception class? A.Exception B. StackMemoryException C. DivideByZeroException D.OutOfMemoryException E. InvalidOperationException

2. Which of the following statements is correct about an Exception? A.It occurs during compilation.

B. It occurs during linking. C.It occurs at run-time. D.It occurs during Just-In-Time compilation. E. It occurs during loading of the program.

3. In C#.NET if we do not catch the exception thrown at runtime then which of the following will catch it? A.Compiler B. CLR C. Linker D.Loader E. Operating system

4. 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"); } } } A.Value 44 will get assigned to a[6] . B. It will output: Index out of bounds C. It will output: Remaining program D.It will not produce any output. E. It will output: Index out of bounds Remaining program

5. Which of the following statements are correct about exception handling in C#.NET? 1. If an exception occurs then the program terminates abruptly without getting any chance to recover from the exception. 2. No matter whether an exception occurs or not, the statements in the finally clause (if present) will get executed. 3. A program can contain multiple finally clauses. 4. A finally clause is written outside the try block. 5. finally clause is used to perform clean up operations like closing the network/database connections.

6. Which of the following statements are correct about exception handling in C#.NET? 1. 2. 3. 4. 5. If our program does not catch an exception then the .NET CLR catches it. It is possible to create user-defined exceptions. All types of exceptions can be caught using the Exception class. CLRExceptions is the base class for all exception classes. For every try block there must be a corresponding finally block.

7. Which of the following statements are correct about the exception reported below? Unhandled Exception: System.lndexOutOfRangeException: Index was outside the bounds of the array: at IndiabixConsoleApplication.MyProgram.SetVal(Int32 index, Int32 val) in D:\Sample\IndiabixConsoleApplication\MyProgram.cs:line 26 at IndiabixConsoleApplication.MyProgram.Main(String[] args) in D:\Sample\IndiabixConsoleApplication\MyProgram.cs:line 20 1. 2. 3. 4. 5. The CLR failed to handle the exception. The class MyProgram belongs to the namespace MyProgram. The function SetVal() was called from Main() in line number 20. The exception occurred in line number 26 in the function SetVal() The runtime exception occurred in the project IndiabixConsoleApplication.

8. Which of the following is the Object Oriented way of handling run-time errors? A.OnError B. HERESULT C.Exceptions D.Error codes E. Setjump and Longjump

9. Which of the following statements is correct about the C#.NET program given

below if a value "6" is input to it? using System; namespace IndiabixConsoleApplication { class MyProgram { static void Main(string[] args) { int index; int val = 44; int[] a = new int[5]; try { Console.Write("Enter a number:"); index = Convert.Tolnt32(Console.ReadLine()); a[index] = val; } catch(FormatException e) { Console.Write("Bad Format"); } catch(IndexOutOfRangeException e) { Console.Write("Index out of bounds"); } Console.Write("Remaining program"); } } } A.It will output: Index out of bounds Remaining program B. It will output: Bad Format Remaining program C. It will output: Bad Format D.It will output: Remaining program E. It will output: Index out of bounds

10. Which of the following statements are correct about the exception reported below? Unhandled Exception: System.lndexOutOfRangeException: Index was outside the bounds of the array. at IndiabixConsoleApplication.Program.Main(String[] args) in D:\ConsoleApplication\Program.cs:line 14 1. The program did not handle an exception called IndexOutOfRangeException.

2. The program execution continued after the exception occurred. 3. The exception occurred in line number 14. 4. In line number 14, the program attempted to access an array element which was beyond the bounds of the array. 5. The CLR could not handle the exception.

11. Which of the following statements are correct about exception handling in C#.NET? 1. 2. 3. 4. 5. try blocks cannot be nested. In one function, there can be only one try block. An exception must be caught in the same function in which it is thrown. All values set up in the exception object are available in the catch block. While throwing a user-defined exception multiple values can be set in the exception, object.

12. Exceptions can be thrown even from a constructor, whereas error codes cannot be returned from a constructor. B.False A.True

13. Which of the following statements is correct about the C#.NET program given below if a value "6" is input to it? using System; namespace IndiabixConsoleApplication { class MyProgram { static void Main (string[] args) { int index; int val = 66; int[] a = new int[5]; try { Consote.Write("Enter a number: "); index = Convert.ToInt32(Console.ReadLine()); a[index] = val; } catch(Exception e) {

Console.Write("Exception occurred "); } Console.Write("Remaining program "); } } } A.It will output: Exception occurred B. It will output: Remaining program C.It will output: Exception occurred Remaining program D.It will output: Remaining program Exception occurred E. The value 66 will get assigned to a[6] .

14. 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 val = 55; int[] a = new int[5]; try { Console.Write("Enter a number: "); index = Convert.ToInt32(Console.ReadLine()); a[index] = val; } catch(FormatException e) { Console.Write("Bad Format "); } catch(IndexOutOfRangeException e) { Console.Write("Index out of bounds "); } Console.Write("Remaining program "); } } } A.It will output: Bad Format B. It will output: Remaining program

C. It will output: Index out of bounds D.It will output: Bad Format Remaining program E. It will output: Index out of bounds Remaining program

15. All code inside finally block is guaranteed to execute irrespective of whether an exception occurs in the protected block or not. B.False A.True

16. Which of the following is NOT an Exception? A.StackOverflow B. Division By Zero C. Insufficient Memory D.Incorrect Arithmetic Expression E. Arithmetic overflow or underflow

17. 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"); } } } A.It will output: Exception occurred

B. It will output: Remaining program C. It will output: Remaining program Exception occurred D.It will output: Exception occurred Remaining program E. The value 88 will get assigned to a[0] .

18. It is compulsory for all classes whose objects can be thrown with throw statement to be derived from System.Exception class. A.True B.False

Collection Classes 1. Which of the following statements are correct about an ArrayList collection that implements the IEnumerable interface? 1. The ArrayList class contains an inner class that implements the IEnumerator interface. 2. An ArrayList Collection cannot be accessed simultaneously by different threads. 3. The inner class of ArrayList can access ArrayList class's members. 4. To access members of ArrayList from the inner class, it is necessary to pass ArrayList class's reference to it.

5. Enumerator's of ArrayList Collection can manipulate the array.

2. How many enumerators will exist if four threads are simultaneously working on an ArrayList object? A. 1 B. 3 C.2 D.4 E. Depends upon the Project Setting made in Visual Studio.NET.

3. In which of the following collections is the Input/Output index-based? 1. 2. 3. 4. 5. Stack Queue BitArray ArrayList HashTable

4. In which of the following collections is the Input/Output based on a key? 1. 2. 3. 4. 5. Map Stack BitArray HashTable SortedList

5. In a HashTable Key cannot be null, but Value can be. A.True B.False

6. Which of the following statements are correct about the C#.NET code snippet given below?
Stack st = new Stack(); st.Push("hello"); st.Push(8.2); st.Push(5); st.Push('b'); st.Push(true);

A. Dissimilar elements like "hello", 8.2, 5 cannot be stored in the same Stack

collection. B. Boolean values can never be stored in Stack collection. C.In the fourth call to Push(), we should write "b" in place of 'b'. To store dissimilar elements in a Stack collection, a method PushAnyType() D. should be used in place of Push(). E. This is a perfectly workable code.

7. Which of the following statements are correct about the Stack collection? 1. 2. 3. 4. 5. It can be used for evaluation of expressions. All elements in the Stack collection can be accessed using an enumerator. It is used to maintain a FIFO list. All elements stored in a Stack collection must be of similar type. Top-most element of the Stack collection can be accessed using the Peek() method.

8. 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? A.t.ContainsKey("Kerala"); B. t.HasValue("Kerala"); C.t.HasKey("Kerala"); D.t.ContainsState("Kerala"); E. t.ContainsValue("Kerala");

9. Which of the following is the correct way to access all elements of the Queue collection created using the C#.NET code snippet given below?
Queue q = new Queue(); q.Enqueue("Sachin"); q.Enqueue('A'); q.Enqueue(false); q.Enqueue(38); q.Enqueue(5.4); IEnumerator e; e = q.GetEnumerator(); A.while (e.MoveNext()) Console.WriteLine(e.Current);

B. IEnumerable e;

e = q.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current); IEnumerator e; e = q.GetEnumerable(); C.while (e.MoveNext()) Console.WriteLine(e.Current); IEnumerator e; e = Queue.GetEnumerator(); D.while (e.MoveNext()) Console.WriteLine(e.Current);

10. Which of the following is NOT an interface declared in System.Collections namespace? A. IComparer B. IEnumerable C.IEnumerator D.IDictionaryComparer E. IDictionaryEnumerator

11. Suppose value of the Capacity property of ArrayList Collection is set to 4. What will be the capacity of the Collection on adding fifth element to it? A. 4 B.8 C.16 D.32

12. Which of the following is an ordered collection class? 1. 2. 3. 4. 5. Map Stack Queue BitArray HashTable

13. Which of the following is the correct way to find out the number of elements currently present in an ArrayList Collection called arr? A.arr.Count B. arr.GrowSize

C.arr.MaxIndex D.arr.Capacity E. arr.UpperBound 14. Which of the following statements are correct about a HashTable collection? 1. 2. 3. 4. 5. It is a keyed collection. It is a ordered collection. It is an indexed collection. It implements a IDictionaryEnumerator interface in its inner class. 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.

15. Which of the following is the correct way to access all elements of the Stack collection created using the C#.NET code snippet given below?
Stack st = new Stack(); st.Push(11); st.Push(22); st.Push(-53); st.Push(33); st.Push(66); IEnumerable e; e = st.GetEnumerator(); A. while (e.MoveNext()) Console.WriteLine(e.Current); IEnumerator e; e = st.GetEnumerable(); B. while (e.MoveNext()) Console.WriteLine(e.Current); IEnumerator e; e = st.GetEnumerator(); C.while (e.MoveNext()) Console.WriteLine(e.Current); IEnumerator e; e = Stack.GetEnumerator(); D.while (e.MoveNext()) Console.WriteLine(e.Current);

16. Which of the following statements are correct about the Collection Classes available in Framework Class Library? A. Elements of a collection cannot be transmitted over a network. B. Elements stored in a collection can be retrieved but cannot be modified.

It is not easy to adopt the existing Collection classes for newtype of objects. Elements stored in a collection can be modified only if allelements are of D. similar types. They use efficient algorithms to manage the collection, thereby E. improving the performance of the program. C.

Enumeration
1. Which of the following statements are correct about an enum used inC#.NET? 1. By default the first enumerator has the value equal to the number of elements present in the list. 2. The value of each successive enumerator is decreased by 1. 3. An enumerator contains white space in its name. 4. A variable cannot be assigned to an enum element. 5. Values of enum elements cannot be populated from a database.

2. Which of the following statements is correct about the C#.NET code snippet given below?
int a = 10; int b = 20; int c = 30; enum color: byte { red = a, green = b, blue = c }

A.Variables cannot be assigned to enum elements. B. Variables can be assigned to any one of the enum elements. C.Variables can be assigned only to the first enum element. D.Values assigned to enum elements must always be successive values. E. Values assigned to enum elements must always begin with 0.

3. Which of the following statements is true about an enum used in C#.NET? A. An implicit cast is needed to convert from enum type to an integral type. B. An enum variable cannot have a public access modifier. C.An enum variable cannot have a private access modifier. D.An enum variable can be defined inside a class or a namespace. E. An enum variable cannot have a protected access modifier.

4. Which of the following is the correct output for the C#.NET code snippet given below?
enum color { red, green, blue } color c; c = color.red; Console.WriteLine(c);

A. 1 C.red E. color.red

B. -1 D.0

5. Which of the following statements are correct about an enum used inC#.NET? 1. 2. 3. 4. 5. To use the keyword enum, we should either use [enum] or System.Enum. enum is a keyword. Enum is class declared in System.Type namespace. Enum is a class declared in the current project's root namespace. Enum is a class declared in System namespace.

6. 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 );

A.-3, -2, -1 B. -3, 0, 1 C.0, 1, 2 D.red, green, blue E. color.red, color.green, color.blue

7. An enum that is declared inside a class, struct, namespace or interface is treated as public. A.True B.False

8. Which of the following statements is correct about the C#.NET code snippet given below?
enum per { married, unmarried, divorced, spinster } per.married = 10; Console.WriteLine(per.unmarried);

A. The program will output a value 11. B. The program will output a value 1. C.The program will output a value 2. D.The program will report an error since an enum element cannot be

assigned a value outside the enum declaration. E. The enum elements must be declared private.

9. Which of the following is the correct output for the C#.NET code snippet given below?
enum color: int { red, green, blue = 5, cyan, magenta = 10, yellow } Console.Write( (int) color.green + ", " ); Console.Write( (int) color.yellow );

A. 2, 11 B.1, 11 C.2, 6 D.1, 5 E. None of the above 10. An enum can be declared inside a class, struct, namespace or interface. A.True B.False

11. Which of the following CANNOT be used as an underlying datatype for an enum in C#.NET? A. byte B. short C.float D.int

12. Which of the following statements are correct about enum used in C#.NET? 1. 2. 3. 4. Every enum is derived from an Object class. Every enum is a value type. There does not exist a way to print an element of an enum as a string. Every enum is a reference type.

5. The default underlying datatype of an enum is int.

13. Which of the following statements is correct about the C#.NET code snippet given below?
enum color : byte { red = 500, green = 1000, blue = 1500 }

A. byte values cannot be assigned to enum elements. B. enum elements should always take successive values. Since 500, 1000, 1500 exceed the valid range of byte compiler will report C. an error. D.enum must always be of int type. E. enum elements should be declared as private.

14. Which of the following is the correct output for the C#.NET code snippet given below?
enum color { red, green, blue } color c = color.red; Type t; t = c.GetType(); string[ ]str; str = Enum.GetNames(t); Console.WriteLine(str[ 0 ]);

A.red C.1 E. color.red

B. 0 D.-1

15. Which of the following statements are correct about the C#.NET code snippet given below?
namespace IndiabixConsoleApplication ( class Sample { private enum color : int { red,

green, blue } public void fun() { Console.WriteLine(color.red); } } class Program { static void Main(string[ ] args) { // Use enum color here } } }

1. To define a variable of type enum color in Main(), we should use the statement, color c; . 2. enum color being private it cannot be used in Main(). 3. We must declare enum color as public to be able to use it outside the class Sample. 4. To define a variable of type enum color in Main(), we should use the statement, Sample.color c; . 5. We must declare private enum color outside the class to be able to use it in Main().

16. Which of the following statements is correct about an enum used in C#.NET? A. enum is a reference type. B.enum is a value type. C.Whether it a value type or a reference type depends upon size. Whether it a value type or a reference type depends upon a Project Setting D. made in Visual Stiiclio.NET. We can programmatically control whether it is a value type or a reference E. type. 17. Which of the following statements are correct about an enum used in C#.NET? 1. An enum can be declared inside a class. 2. An enum can take Single, Double or Decimal values.

3. An enum can be declared outside a class. 4. An enum can be declared inside/outside a namespace. 5. An object can be assigned to an enum variable.

Attributes
1. The [Serializable()] attribute gets inspected at A. Compile-time B.Run-time C.Design-time D.Linking-time E. None of the above

2. Which of the following are correct ways to specify the targets for a custom

attribute? A. By applying AttributeUsage to the custom attribute's class definition. B. By applying UsageAttribute to the custom attribute's class definition. C.Once an attribute is declared it applies to all the targets. By applying AttributeUsageAttribute to the custom attribute's class D. definition. E. None of the above.

3. Which of the following are correct ways to pass a parameter to an attribute? 1. 2. 3. 4. 5. By value By reference By address By position By name

4. Which of the following statements are correct about inspecting an attribute in C#.NET? 1. 2. 3. 4. An attribute can be inspected at link-time. An attribute can be inspected at compile-time. An attribute can be inspected at run-time. An attribute can be inspected at design-time.

5. Which of the following is correct ways of applying an attribute?


[WebService (Name = "IndiaBIX", Description = "BIX WebService")] A.class AuthenticationService: WebService { /* .... */} <WebService ( Name : "IndiaBIX", Description : "BIX WebService" )> B. class AuthenticationService: inherits WebService { /* .... */} <WebService ( Name = "IndiaBIX", Description = "BIX WebService" )> C.class AuthenticationService: extends WebService { /* .... */} [WebService ( Name := "IndiaBIX", Description := "BIX WebService")] D.class AuthenticationService: inherits WebService { /* .... */}

6. Which of the following statements are correct about Attributes used in C#.NET? A. If there is a custom attribute BugFixAttribute then the compiler will look

ONLY for the BugFix attribute in the code that uses this attribute. To create a custom attribute we need to create a custom attribute structure B. and derive it from System.Attribute. To create a custom attribute we need to create a class and implement C. IAttribute interface in it. If a BugFixAttribute is to receive three parameters then the BugFixAttribute D. class should implement a zero-argument constructor. The CLR can change the behaviour of the code depending upon the E. attributes applied to it.

7. Which of the following forms of applying an attribute is correct? A. { /* ... */ } B. { /* ... */ } C.{ /* ... */ }
< Serializable() > class sample (Serializable()) class sample [ Serializable() ] class sample Serializablef) class sample

D.{ /* ... */ } E. None of the above

8. Which of the following statements are correct about Attributes in C#.NET? 1. On compiling a C#.NET program the attibutes applied are recorded in the metadata of the assembly. 2. On compilation all the attribute's tags are deleted from the program. 3. It is not possible to create custom attributes.. 4. The attributes applied can be read from an assembly using Reflection class. 5. An attribute can have parameters.

9. Which of the following correctly describes the contents of the filename AssemblyInfo.cs? A. It contains method-level attributes. B. It contains class-level attributes. C.It contains assembly-level attributes. D.It contains structure-level attributes. E. It contains namespace-level attributes. 10. It possible to create a custom attribute that can be applied only to specific programming element(s) like ____ . A. Classes B. Methods C.Classes and Methods

D.Classes, Methods and Member-Variables 11. Which of the following CANNOT be a target for a custom attribute? A. Enum B. Event C.Delegate D.Interface E. Namespace 12. Once applied which of the following CANNOT inspect the applied attribute? A. CLR B.Linker C.ASP.NET Runtime D.Visual Studio.NET E. Language compilers 13. Which of the following is the correct way to apply an attribute to an Assembly? A. [ AssemblyDescription("DCube Component Library") ] B.[ assembly : AssemblyDescription("DCube Component Library") ] C.[ Assemblylnfo : AssemblyDescription("DCube Component Library") ] D.< Assembly: AssemblyDescription("DCube Component Library") > E. (Assembly: AssemblyDescription("DCube Component Library")) 14. Which of the following is the correct way of applying the custom attribute called Tested which receives two-arguments - name of the tester and the testgrade? 1. Custom attribute cannot be applied to an assembly. 2. [assembly: Tested("Sachin", testgrade.Good)] 3. [Tested("Virat", testgrade.Excellent)] class customer { /* .... */ } 4. Custom attribute cannot be applied to a method. 5. Custom attribute cannot be applied to a class.

15.

Attributes can be applied to 1. 2. 3. 4. 5. Method Class Assembly Namespace Enum

Generics
1. Which one of the following classes are present System.Collections.Generic namespace? 1. 2. 3. 4. Stack Tree SortedDictionary SortedArray

2. For the code snippet shown below, which of the following statements are valid?
public class Generic<T> { public T Field; public void TestSub() { T i = Field + 1; } } class MyProgram { static void Main(string[] args) { Generic<int> gen = new Generic<int>(); gen.TestSub(); } }

A. Addition will produce result 1. B. Result of addition is system-dependent. C.Program will generate run-time exception. Compiler will report an error: Operator '+' is not defined for types T and D. int. E. None of the above.

3. Which of the following statements are valid about generics in .NET Framework? 1. Generics is a language feature. 2. We can create a generic class, however, we cannot create a generic interface in C#.NET. 3. Generics delegates are not allowed in C#.NET. 4. Generics are useful in collection classes in .NET framework. 5. None of the above

4. Which of the following statements is valid about generic procedures in C#.NET? A. All procedures in a Generic class are generic. B. Only those procedures labeled as Generic are generic. C.Generic procedures can take at the most one generic parameter. D.Generic procedures must take at least one type parameter. E. None of the above.

5. For the code snippet shown below, which of the following statements are valid?
public class TestIndiaBix

{ public void TestSub<M> (M arg) { Console.Write(arg); } } class MyProgram { static void Main(string[] args) { TestIndiaBix bix = new TestIndiaBix(); bix.TestSub("IndiaBIX "); bix.TestSub(4.2f); } }

A.Program will compile and on execution will print: IndiaBIX 4.2 B. A non generic class Hello cannot have generic subroutine. C.Compiler will generate an error. D.Program will generate a run-time exception. E. None of the above.

6. For the code snippet given below, which of the following statements is valid?
public class Generic<T> { public T Field; } class Program { static void Main(string[ ] args) { Generic<String> g = new Generic<String>(); g.Field = "Hello"; Console.WriteLine(g.Field); } }

A. It will print string "Hello" on the console. B. Name Generic cannot be used as a class name because it's a keyword. C.Compiler will give an error. D.Member Field of class Generic is not accessible directly. E. None of the above.

7. For the code snippet given below, which of the following statements are valid?
public class MyContainer<T> where T: IComparabte { // Insert code here }

1. Class MyContainer requires that it's type argument must implement IComparabte interface. 2. Type argument of class MyContainer must be IComparabte. 3. Compiler will report an error for this block of code. 4. This requirement on type argument is called as constraint.

8. For the code snippet given below, which of the following statements are valid?
public class MyContainer<T> where T: class, IComparable { //Insert code here }

1. Class MyContainer requires that it's type argument must implement IComparable interface. 2. Compiler will report an error for this block of code. 3. There are multiple constraints on type argument to MyContainer class. 4. Class MyContainer requires that its type argument must be a reference type and it must implement IComparable interface.

9. Which of the following statements is valid about advantages of generics? Generics shift the burden of type safety to the programmer rather than A. compiler. B. Generics require use of explicit type casting. Generics provide type safety without the overhead of multiple C. implementations. D.Generics eliminate the possibility of run-time errors. E. None of the above.

Delegates
1. Which of the following statements is incorrect about delegate? A. Delegates are reference types. B. Delegates are object oriented. C.Delegates are type-safe. Delegates serve the same purpose as function pointers in C and pointers to D. member function operators in C++. E. Only one method can be called using a delegate.

2. In which of the following areas are delegates commonly used? 1. 2. 3. 4. 5. Remoting Serialization File Input/Output Multithreading Event handling

3. Which of the following is the necessary condition for implementing delegates? A.Class declaration B. Inheritance C.Run-time Polymorphism D.Exceptions E. Compile-time Polymorphism

4. Which of the following statements are correct about the delegate declaration given below?
delegate void del(int i);

1. On declaring the delegate a class called del will get created. 2. The signature of del need not be same as the signature of the method that we intend to call using it. 3. The del class will be derived from the MulticastDelegate class. 4. The method that can be called using del should not be a static method. 5. The del class will contain a one-argument constructor and an lnvoke() method.

5. Which of the following is the correct way to call the function MyFun() of the Sample class given below?
class Sample { public int MyFun(int i) { Console.WriteLine("Welcome to IndiaBIX.com !" ); return 0; } } delegate void del(int i); A. Sample s = new Sample();

deld = new del(ref s.MyFun); d(10); delegate int del(int i); Sample s = new Sample(.); B. del = new delegate(ref MyFun); del(10); Sample s = new Sample(); delegate void del = new delegate(ref MyFun); C.del(10); delegate int del(int i); del d; D.Sample s = new Sample(); d = new del(ref s.MyFun); d(10);

6. Which of the following is the correct way to call subroutine MyFun() of the Sample class given below?
class Sample { public void MyFun(int i, Single j) { Console.WriteLine("Welcome to IndiaBIX !"); } } delegate void del(int i); Sample s = new Sample(); A. del d = new del(ref s.MyFun); d(10, 1.1f); delegate void del(int i, Single j); del d; B.Sample s = new Sample(); d = new del(ref s.MyFun); d(10, 1.1f); Sample s = new Sample(); C.delegate void d = new del(ref MyFun); d(10, 1.1f); delegate void del(int i, Single]); Sample s = new Sample(); D.del = new delegate(ref MyFun); del(10, 1.1f);

7. Which of the following statements are correct about a delegate? 1. Inheritance is a prerequisite for using delegates. 2. Delegates are type-safe. 3. Delegates provide wrappers for function pointers.

4. The declaration of a delegate must match the signature of the method that we intend to call using it. 5. Functions called using delegates are always late-bound.

8. Which of the following statements are correct about delegates? 1. 2. 3. 4. 5. Delegates are not type-safe. Delegate is a user-defined type. Only one method can be bound with one delegate object. Delegates can be used to implement callback notification. Delegates permit execution of a method on a secondary thread in an asynchronous manner.

9. Which of the following statements are correct about delegates? A. Delegates cannot be used to call a static method of a class. Delegates cannot be used to call procedures that receive variable number B. of arguments. If signatures of two methods are same they can be called through the same C. delegate object. Delegates cannot be used to call an instance function. Delegates cannot be D. used to call an instance subroutine.

10. Which of the following are the correct ways to declare a delegate for calling the function func() defined in the sample class given below?
class Sample { public int func(int i, Single j) { /* Add code here. */ } }

A. delegate d(int i, Single j); B. delegate void d(int, Single); C.delegate int d(int i, Single j); D.delegate void (int i, Single j);

E. delegate int sample.func(int i, Single j);

11. 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? A. Attribute B.Delegate C.Namespace D.Interface E. Encapsulation

12. Which of the following statements is incorrect about a delegate? A. A single delegate can invoke more than one method. B. Delegates can be shared. C.Delegate is a value type. D.Delegates are type-safe wrappers for function pointers. The signature of a delegate must match the signature of the method that is E. to be called using it.

13. Suppose a Generic class called SortObjects is to be made capable of sorting objects of any type (Integer, Single, Byte etc.). Which of the following programming constructs should be used to implement the comparision function? A. Namespace B. Interface C.Encapsulation D.Delegate E. Attribute

14. With which of the following can the ref keyword be used? 1. 2. 3. 4. Static data Instance data Static function/subroutine Instance function/subroutine

When Enable editing is done in gridview "BoundField" and "UpdateParameters" has a property "ConvertEmptyStringToNull". This property is true by default. If you want to store an "EmptyString" instead of NULL, set this property to false. --means v can store no value when click on update button or link.. This property need to be set at both places. 1. On the BoundField and 2. On the respective update parameter The bound column that displays "EmployeeId" is marked with ReadOnly="True". This is the reason EmployeeId is not editable, when the row is in EDIT mode. --others columns get highlighted but primary key column is read only..cant modify it

During updation suppose column like gender or country is there means v can select one option from more than one then v can convert it into template fieldselect edit template field..then select edit item template because v r making changes ..n v can add any ctrl v want it.can add dropdwonlist hereit makes UI better Difference between eval and bind is
<asp:Label ID="Label1" runat="server" Text='<%#Eval("EmpId") %>'></asp:Label> <asp:Label ID="Label1" runat="server" Text='<%# Bind("EmpId") %>'></asp:Label>

Eval() is one-way binding and Bind() is two way binding Eval means cant update that value associated with field..its read only.or its primary key value

Das könnte Ihnen auch gefallen