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.

1.

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;

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

Which of the following can implement an interface? Data Class Enum Structure Namespace

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

Which of the following statements are correct about an interface in C#.NET? A class can implement multiple interfaces. Structures cannot inherit a class but can implement an interface. In C#.NET, : is used to signify that a class member implements a specific interface. An interface can implement multiple classes. The static attribute can be used with a method that implements an interface declaration.

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

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

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?

A. <pre><code class="csharp">class Student { int[] scores = new int[5] {3, 2, 4,1, 5}; public int this[ int index ] { set { if (index &lt; 5) scores[index] = value; else Console.WriteLine("Invalid Index"); } } }</code></pre>
B. <pre><code class="csharp">class Student { int[] scores = new int[5] {3, 2, 4, 1, 5}; public int this[ int index ] { get { if (index &lt; 5) return scores[ index ]; else { Console.WriteLine("Invalid Index"); return 0; } } set { if (index &lt; 5) scores[ index ] = value; else Console.WriteLine("Invalid Index"); } } }</code></pre>
C. <pre><code class="csharp">class Student { int[] scores = new int[5] {3, 2, 4, 1, 5}; public int this[ int index ] { get { if (index &lt; 5) return scores[ index ]; else { Console.WriteLine("Invalid Index"); return 0; } } } }</code></pre>
D. <pre><code class="csharp">class Student { int[] scores = new int[5] {3, 2, 4, 1, 5}; public int this[ int index ] { get { if (index &lt; 5) scores[ index ] = value; else { Console.WriteLine("Invalid Index"); } } set { if (index &lt; 5) return scores[ index ]; else { Console.WriteLine("Invalid Index"); return 0; } } } }</code></pre>
Answer» C. <pre><code class="csharp">class Student { int[] scores = new int[5] {3, 2, 4, 1, 5}; public int this[ int index ] { get { if (index &lt; 5) return scores[ index ]; else { Console.WriteLine("Invalid Index"); return 0; } } } }</code></pre>
6.

If Sample class has a Length property with set accessor then which of the following statements will work correctly?

A. <pre><code class="csharp">Sample m = new Sample(); int l; l = m.Length;</code></pre>
B. <pre><code class="csharp">Sample m = new Sample(); m.Length = m.Length + 20;</code></pre>
C. <pre><code class="csharp">Sample.Length = 20;</code></pre>
D. <pre><code class="csharp">Console.WriteLine (Sample.Length);</code></pre>
E. <pre><code class="csharp">Sample m = new Sample(); m.Length = 10;</code></pre>
Answer» F.
7.

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
B. 4
C. 18
D. 10
E. 5
Answer» D. 10
8.

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

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

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

A. 1 and 2 only
B. 1, 2 and 3 only
C. 4 and 5 only
D. All of the above
E. None of the above
Answer» C. 4 and 5 only
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.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 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.

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

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
Answer» B. It will output: Bad Format Remaining program
12.

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}; intMyArr.GetMax; intMyArr.Highest(0); intMyArr.GetUpperBound(0); intMyArr.Length; intMyArr.GetMaxElements(0);

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

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
Answer» E. Arithmetic overflow or underflow
14.

Which of the folowing does an indexer allow to index in the same way as an array? A class A property A struct A function An interface

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

If Sample class has a Length property with get accessor then which of the following statements will work correctly?

A. <pre><code class="csharp">Sample m = new Sample(); m.Length = 10;</code></pre>
B. <pre><code class="csharp">Sample m = new Sample(); m.Length = m.Length + 20;</code></pre>
C. <pre><code class="csharp">Sample m = new Sample(); int l; l = m.Length;</code></pre>
D. <pre><code class="csharp">Sample.Length = 20;</code></pre>
E. <pre><code class="csharp">Console.WriteLine(Sample.Length);</code></pre>
Answer» D. <pre><code class="csharp">Sample.Length = 20;</code></pre>
16.

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

A. 3
B. 4
C. 7
D. 9
E. 2
Answer» F.
17.

A property can be declared inside a namespace or a procedure.

A. True
B. False
Answer» C.
18.

Which of the following can be declared in an interface? Properties Methods Enumerations Events Structures

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

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
Answer» C. 0 byte
20.

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

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

Which of the following statements are correct about the C#.NET code snippet given below? int[ , ] intMyArr = {{7, 1, 3}, {2, 9, 6}}; 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.

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

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. <pre><code class="csharp">int[] a = new int[5]; int[] a = new int[10];</code></pre>
B. <pre><code class="csharp">int[] a = int[5]; int[] a = int[10];</code></pre>
C. <pre><code class="csharp">int[] a = new int[5]; a.Length = 10 ;</code></pre>
D. <pre><code class="csharp">int[] a = new int[5]; a = new int[10];</code></pre>
E. <pre><code class="csharp">int[] a = new int[5]; a.GetUpperBound(10);</code></pre>
Answer» E. <pre><code class="csharp">int[] a = new int[5]; a.GetUpperBound(10);</code></pre>
23.

Which of the following is NOT a .NET Exception class?

A. <i class="csharp-code">Exception</i>
B. <i class="csharp-code">StackMemoryException</i>
C. <i class="csharp-code">DivideByZeroException</i>
D. <i class="csharp-code">OutOfMemoryException</i>
E. <i class="csharp-code">InvalidOperationException</i>
Answer» C. <i class="csharp-code">DivideByZeroException</i>
24.

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. <i class="csharp-code">foreach (int j = 1; j &lt; a(0).GetUpperBound; j++)</i>
B. <i class="csharp-code">foreach (int j = 1; j &lt; a.GetUpperBound (0); j++)</i>
C. <i class="csharp-code">foreach (int j in a.Length)</i>
D. <i class="csharp-code">foreach (int j in i)</i>
E. <i class="csharp-code">foreach (int j in a.Length -1)</i>
Answer» E. <i class="csharp-code">foreach (int j in a.Length -1)</i>
25.

A property can be declared inside a class, struct, Interface.

A. True
B. False
Answer» B. False
26.

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

A. <pre><code class="csharp">e.name = "Amol"; e.age = 25; e.sal = 5500;</code></pre>
B. <pre><code class="csharp">With e { .name = "Amol"; .age = 25; .sal = 5500; }</code></pre>
C. <pre><code class="csharp">With emp e { .name = "Amol"; .age = 25; .sal = 5500; }</code></pre>
D. <pre><code class="csharp">e -&gt; name = "Amol"; e -&gt; age = 25; e -&gt; sal = 5500;</code></pre>
E. <pre><code class="csharp">name = "Amol"; age = 25; sal = 5500;</code></pre>
Answer» B. <pre><code class="csharp">With e { .name = "Amol"; .age = 25; .sal = 5500; }</code></pre>
27.

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

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

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

C#.NET structures are always value types.

A. True
B. False
Answer» B. False
30.

Which of the following statements are correct? 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.

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

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

A. <pre><code class="csharp">Bix1 method 123 Bixl method Bix2 method</code></pre>
B. <pre><code class="csharp">Bix1 method 123 Bix2 method</code></pre>
C. <pre><code class="csharp">Bix2 method 123 Bix2 method Bixl method</code></pre>
D. <pre><code class="csharp">Bixl method 123</code></pre>
E. <pre><code class="csharp">Bix2 method 123 Bixl method</code></pre>
Answer» B. <pre><code class="csharp">Bix1 method 123 Bix2 method</code></pre>
32.

Is it possible to invoke Garbage Collector explicitly?

A. Yes
B. No
Answer» B. No
33.

Is it possible for you to prevent an object from being created by using zero argument constructor?

A. Yes
B. No
Answer» B. No
34.

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.
Answer» E.
35.

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. <i class="csharp-code">Sample s1 = new Sample();</i>
B. <i class="csharp-code">Sample s1 = new Sample(10);</i>
C. <i class="csharp-code">Sample s2 = new Sample(10, 1.2f);</i>
D. <i class="csharp-code">Sample s3 = new Sample(10, 1.2f, 2.4);</i>
E. <i class="csharp-code">Sample s1 = new Sample(, , 2.5);</i>
Answer» E. <i class="csharp-code">Sample s1 = new Sample(, , 2.5);</i>
36.

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,
Answer» C. 11, 11, 11, 11,
37.

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 &lt; 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
Answer» D. 5 25 125 625 3125
38.

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

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

Which of the following security features can .NET applications avail? PIN Security Code Access Security Role Based Security Authentication Security Biorhythm Security

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

Which of the following statements are correct about a .NET Assembly? It is the smallest deployable unit. Each assembly has only one entry point - Main(), WinMain() or DLLMain(). An assembly can be a Shared assembly or a Private assembly. An assembly can contain only code and data. An assembly is always in the form of an EXE file.

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

Which of the following statements are correct about JIT? JIT compiler compiles instructions into machine code at run time. The code compiler by the JIT compiler runs under CLR. The instructions compiled by JIT compilers are written in native code. The instructions compiled by JIT compilers are written in Intermediate Language (IL) code. The method is JIT compiled even if it is not called

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

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

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

Code that targets the Common Language Runtime is known as

A. Unmanaged
B. Distributed
C. Legacy
D. Managed Code
E. Native Code
Answer» E. Native Code
44.

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

A. Only 1 and 2
B. Only 2, 3 and 4
C. Only 1, 2 and 4
D. Only 4
E. All of the above
Answer» F.
45.

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
Answer» B. Common Language Runtime
46.

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

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

Which of the following is another way to rewrite the code snippet given below? int a = 1, b = 2, c = 0; if (a &lt; b) c = a;

A. <pre><code class="csharp">int a = 1, b = 2, c = 0; c = a &lt; b ? a : 0;</code></pre>
B. <pre><code class="csharp">int a = 1, b = 2, c = 0; a &lt; b ? c = a : c = 0;</code></pre>
C. <pre><code class="csharp">int a = 1, b = 2, c = 0; a &lt; b ? c = a : c = 0 ? 0 : 0;</code></pre>
D. <pre><code class="csharp">int a = 1, b = 2, c = 0; a &lt; b ? return (c): return (0);</code></pre>
E. <pre><code class="csharp">int a = 1, b = 2,c = 0; c = a &lt; b : a ? 0;</code></pre>
Answer» B. <pre><code class="csharp">int a = 1, b = 2, c = 0; a &lt; b ? c = a : c = 0;</code></pre>
48.

Which of the following statements are correct? 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. The goto statement passes control to the next iteration of the enclosing iteration statement in which it appears. Branching is performed using jump statements which cause an immediate transfer of the program control. A common use of continue is to transfer control to a specific switch-case label or the default label in a switch statement. The do statement executes a statement or a block of statements enclosed in {} repeatedly until a specified expression evaluates to false.

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

Which of the following loop correctly prints the elements of the array? char[ ] arr = new char[ ] {'k', 'i','C', 'i','t'} ;

A. <pre><code class="csharp">do { Console.WriteLine((char) i); } while (int i = 0; i &lt; arr; i++);</code></pre>
B. <pre><code class="csharp">foreach (int i in arr) { Console.WriteLine((char) i); }</code></pre>
C. <pre><code class="csharp">for (int i = 0; i &lt; arr; i++) { Console.WriteLine((char) i); }</code></pre>
D. <pre><code class="csharp">while (int i = 0; i &lt; arr; i++) { Console.WriteLine((char) i); }</code></pre>
E. <pre><code class="csharp">do { Console.WriteLine((char) i); } until (int i = 0; i &lt; arr; i++);</code></pre>
Answer» C. <pre><code class="csharp">for (int i = 0; i &lt; arr; i++) { Console.WriteLine((char) i); }</code></pre>
50.

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

A. Prime
B. Fibonacci
C. Palindrome
D. Odd
E. Even
Answer» C. Palindrome