Explore topic-wise MCQs in Engineering.

This section includes 299 Mcqs, each offering curated multiple-choice questions to sharpen your Engineering knowledge and support exam preparation. Choose a topic below to get started.

151.

Which of the following statements are correct about exception handling in C#.NET? 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.

A. 1 only
B. 1 and 2 only
C. 3 only
D. 4 and 5 only
E. All of the above
Answer» E. All of the above
152.

Which of the following statements are correct about the this reference? 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. While calling an instance member function we are not required to pass the this reference explicitly.

A. 1, 4
B. 2, 3, 5
C. 3, 4
D. 2, 5
E. None of these
Answer» C. 3, 4
153.

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

A. 1, 3
B. 2, 4
C. 4, 5
D. 3, 5
E. None of these
Answer» D. 3, 5
154.

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
Answer» C. 8 bytes
155.

Which of the following statements are correct about Structures used in C#.NET? A Structure can be declared within a procedure. Structs can implement an interface but they cannot inherit from another struct. struct members cannot be declared as protected. A Structure can be empty. 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
Answer» C. 2, 4
156.

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 !"); } }

A. <pre><code class="csharp">delegate void del(int i); Sample s = new Sample(); del d = new del(ref s.MyFun); d(10, 1.1f);</code></pre>
B. <pre><code class="csharp">delegate void del(int i, Single j); del d; Sample s = new Sample(); d = new del(ref s.MyFun); d(10, 1.1f);</code></pre>
C. <pre><code class="csharp">Sample s = new Sample(); delegate void d = new del(ref MyFun); d(10, 1.1f);</code></pre>
D. <pre><code class="csharp">delegate void del(int i, Single]); Sample s = new Sample(); del = new delegate(ref MyFun); del(10, 1.1f);</code></pre>
Answer» C. <pre><code class="csharp">Sample s = new Sample(); delegate void d = new del(ref MyFun); d(10, 1.1f);</code></pre>
157.

In a HashTable Key cannot be null, but Value can be.

A. True
B. False
Answer» B. False
158.

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

A. <pre><code class="csharp">IEnumerable e; e = st.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);</code></pre>
B. <pre><code class="csharp">IEnumerator e; e = st.GetEnumerable(); while (e.MoveNext()) Console.WriteLine(e.Current);</code></pre>
C. <pre><code class="csharp">IEnumerator e; e = st.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);</code></pre>
D. <pre><code class="csharp">IEnumerator e; e = Stack.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);</code></pre>
Answer» D. <pre><code class="csharp">IEnumerator e; e = Stack.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);</code></pre>
159.

Which of the following can be declared as a virtual in a class? Methods Properties Events Fields Static fields

A. 1, 2, 3
B. 3, 5
C. 2, 4
D. 2, 3, 5
Answer» B. 3, 5
160.

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.
Answer» C. The properties in the interface must have a body.
161.

Which of the following is the correct implementation of the interface given below? interface IMyInterface { double MyFun(Single i); }

A. <pre><code class="csharp">class MyClass { double MyFun(Single i) as IMyInterface.MyFun { // Some code } }</code></pre>
B. <pre><code class="csharp">class MyClass { MyFun (Single i) As Double { // Some code } }</code></pre>
C. <pre><code class="csharp">class MyClass: implements IMyInterface { double fun(Single si) implements IMyInterface.MyFun() { //Some code } }</code></pre>
D. <pre><code class="csharp">class MyClass: IMyInterface { double IMyInterface.MyFun(Single i) { // Some code } }</code></pre>
Answer» E.
162.

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
B. -1
C. red
D. 0
E. color.red
Answer» D. 0
163.

Which of the following statements are correct about constructors in C#.NET? 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.

A. 1, 3, 5
B. 2, 3, 4
C. 3, 5
D. 4, 5
E. None of these
Answer» C. 3, 5
164.

What will be the output of the code snippet given below? int i; for(i = 0; i&lt;=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
Answer» D. 4 5 6 7 8 9 10
165.

What will be the output of the C#.NET code snippet given below? byte b1 = 0xF7; byte b2 = 0xAB; byte temp; temp = (byte)(b1 &amp; b2); Console.Write (temp + " "); temp = (byte)(b1^b2); Console.WriteLine(temp);

A. 163 92
B. 92 163
C. 192 63
D. 0 1
Answer» B. 92 163
166.

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
Answer» D. 25, 0
167.

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; } } } 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. It will output 25 125. It will output 25 0. It will output 0 125. An error will be reported in the statement return ss, cc; since a function cannot return multiple values.

A. 1, 3
B. 2, 4
C. 4, 5
D. 1, 5
E. None of these
Answer» E. None of these
168.

The this reference gets created when a member function (non-shared) of a class is called.

A. True
B. False
Answer» B. False
169.

Which of the following constitutes the .NET Framework? ASP.NET Applications CLR Framework Class Library WinForm Applications Windows Services

A. 1, 2
B. 2, 3
C. 3, 4
D. 2, 5
Answer» C. 3, 4
170.

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

A. 1, 3
B. 2, 5
C. 1, 4, 5
D. 3, 4, 5
E. None of these
Answer» D. 3, 4, 5
171.

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
Answer» E. None of the above
172.

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.
Answer» B. 0
173.

Which of the following statements are TRUE about the .NET CLR? It provides a language-neutral development &amp; execution environment. It ensures that an application would not be able to access memory that it is not authorized to access. It provides services to run "managed" applications. The resources are garbage collected. It provides services to run "unmanaged" applications.

A. Only 1 and 2
B. Only 1, 2 and 4
C. 1, 2, 3, 4
D. Only 4 and 5
E. Only 3 and 4
Answer» D. Only 4 and 5
174.

Which of the following is the correct output for the C#.NET program given below? int i = 20 ; for( ; ; ) { Console.Write(i + " "); if (i &gt;= -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
Answer» D. 16 12 8 4 0
175.

Which of the following statements correctly define .NET Framework?

A. It is an environment for developing, building, deploying and executing Desktop Applications, Web Applications and Web Services.
B. It is an environment for developing, building, deploying and executing only Web Applications.
C. It is an environment for developing, building, deploying and executing Distributed Applications.
D. It is an environment for developing, building, deploying and executing Web Services.
E. It is an environment for development and execution of Windows applications.
Answer» B. It is an environment for developing, building, deploying and executing only Web Applications.
176.

Which of the following statements are correct? 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. All of the expressions of the for statement are not optional.

A. 1, 2
B. 2, 3
C. 3, 5
D. 4, 5
E. None of these
Answer» B. 2, 3
177.

Which of the following can be facilitated by the Inheritance mechanism? 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.

A. 1, 2, 3
B. 3, 4
C. 2, 4, 5
D. 3, 5
Answer» B. 3, 4
178.

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
Answer» F.
179.

Which of the following statements will correctly copy the contents of one string into another ?

A. <pre><code class="csharp">String s1 = "String"; String s2; s2 = s1;</code></pre>
B. <pre><code class="csharp">String s1 = "String" ; String s2; s2 = String.Concat(s1, s2);</code></pre>
C. <pre><code class="csharp">String s1 = "String"; String s2; s2 = String.Copy(s1);</code></pre>
D. <pre><code class="csharp">String s1 = "String"; String s2; s2 = s1.Replace();</code></pre>
E. <pre><code class="csharp">String s1 = "String"; String s2; s2 = s2.StringCopy(s1);</code></pre>
Answer» D. <pre><code class="csharp">String s1 = "String"; String s2; s2 = s1.Replace();</code></pre>
180.

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
Answer» C. 5 5
181.

Which of the following are correct ways to pass a parameter to an attribute? By value By reference By address By position By name

A. 1, 2
B. 1, 2, 3
C. 4, 5
D. All of the above
Answer» D. All of the above
182.

Which of the following statements are correct about inspecting an attribute in C#.NET? 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.

A. 1, 2
B. 3, 4
C. 1, 3, 4
D. All of the above
E. None of the above
Answer» B. 3, 4
183.

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
Answer» D. Error codes
184.

Exceptions can be thrown even from a constructor, whereas error codes cannot be returned from a constructor.

A. True
B. False
Answer» B. False
185.

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
Answer» E. It will output: Index out of bounds Remaining program
186.

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.
C. A class that implements an interface can explicitly implement members of that interface.
D. The functions declared in an interface have a body.
Answer» D. The functions declared in an interface have a body.
187.

It is illegal to make objects of one class as members of another class.

A. True
B. False
Answer» B. False
188.

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
Answer» B. 12 bytes
189.

In an inheritance chain which of the following members of base class are accessible to the derived class members? static protected private shared public

A. 1, 3
B. 2, 5
C. 3, 4
D. 4, 5
Answer» C. 3, 4
190.

The space required for structure variables is allocated on stack.

A. True
B. False
Answer» B. False
191.

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; } Emp e(); e = new Emp(); Emp e = new Emp; Emp e; e = new Emp; Emp e = new Emp(); Emp e;

A. 1, 3
B. 2, 5
C. 4, 5
D. 1, 2, 4
Answer» D. 1, 2, 4
192.

Which of the following CANNOT be a target for a custom attribute?

A. Enum
B. Event
C. Delegate
D. Interface
E. Namespace
Answer» F.
193.

In which of the following collections is the Input/Output based on a key? Map Stack BitArray HashTable SortedList

A. 1 and 2 only
B. 2 and 3 only
C. 1, 2 and 3 only
D. 4 and 5 only
E. All of the above
Answer» E. All of the above
194.

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;

A. <pre><code class="csharp">class Student { int[ ] a = new int[5, 5]; public property WriteOnly int this[int i, int j] { set { a[i, j] = value; } } }</code></pre>
B. <pre><code class="csharp">class Student { int[ , ] a = new int[5, 5]; public int property WriteOnly { set { a[i, j] = value; } } }</code></pre>
C. <pre><code class="csharp">class Student { int[ , ] a = new int[5, 5]; public int this[int i, int j] { set { a[i, j] = value; } } }</code></pre>
D. <pre><code class="csharp">class Student { int[ , ] a = new int[5, 5]; int i, j; public int this { set { a[i, j] = value; } } }</code></pre>
Answer» D. <pre><code class="csharp">class Student { int[ , ] a = new int[5, 5]; int i, j; public int this { set { a[i, j] = value; } } }</code></pre>
195.

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 The program did not handle an exception called IndexOutOfRangeException. The program execution continued after the exception occurred. The exception occurred in line number 14. In line number 14, the program attempted to access an array element which was beyond the bounds of the array. The CLR could not handle the exception.

A. 1 only
B. 1, 2 and 3 only
C. 2 and 5 only
D. 1, 3 and 4 only
E. None of the above
Answer» E. None of the above
196.

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
Answer» C.
197.

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.
E. We need to organise the classes declared in Framework Class Library into different namespaces.
Answer» B. A namespace can contain a class but not another namespace.
198.

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. <i class="csharp-code">new</i>
B. <i class="csharp-code">base</i>
C. <i class="csharp-code">virtual</i>
D. <i class="csharp-code">overrides</i>
E. <i class="csharp-code">overloads</i>
Answer» D. <i class="csharp-code">overrides</i>
199.

Which of the following statements is correct about an interface used in C#.NET?

A. If a class implements an interface partially, then it should be 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.
Answer» B. A class cannot implement an interface partially.
200.

Which of the following statements are correct about an interface used in C#.NET? 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.

A. 1, 2
B. 1, 4, 5
C. 3, 4
D. 3 only
Answer» C. 3, 4