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.

251.

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

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

Which of the following statements are correct about enum used in C#.NET? 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. The default underlying datatype of an enum is int.

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

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

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

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

A. <pre><code class="csharp">public Sample() { i = 0; j = 0.0f; } public Sample (int ii, Single jj) { i = ii; j = jj; }</code></pre>
B. <pre><code class="csharp">public Sample (Optional int ii = 0, Optional Single jj = 0.0f) { i = ii; j = jj; }</code></pre>
C. <pre><code class="csharp">public Sample (int ii, Single jj) { i = ii; j = jj; }</code></pre>
D. <pre><code class="csharp">Sample s;</code></pre>
E. <pre><code class="csharp">s = new Sample();</code></pre>
Answer» B. <pre><code class="csharp">public Sample (Optional int ii = 0, Optional Single jj = 0.0f) { i = ii; j = jj; }</code></pre>
255.

There is no private or protected inheritance in C#.NET.

A. True
B. False
Answer» B. False
256.

If a base class contains a member function func(), and a derived class does not contain a function with this name, an object of the derived class cannot access func().

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

Creating empty structures is allowed in C#.NET.

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

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.
E. The signature of a delegate must match the signature of the method that is to be called using it.
Answer» D. Delegates are type-safe wrappers for function pointers.
259.

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

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

The [Serializable()] attribute gets inspected at

A. Compile-time
B. Run-time
C. Design-time
D. Linking-time
E. None of the above
Answer» C. Design-time
261.

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

Which of the following statements is incorrect about delegate?

A. Delegates are reference types.
B. Delegates are object oriented.
C. Delegates are type-safe.
D. Delegates serve the same purpose as function pointers in C and pointers to member function operators in C++.
E. Only one method can be called using a delegate.
Answer» F.
263.

With which of the following can the ref keyword be used? Static data Instance data Static function/subroutine Instance function/subroutine

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

Which of the following C#.NET code snippets will correctly print "Hello C#.NET"?

A. <pre><code class="csharp">import System; namespace IndiabixConsoleApplication { class MyProgram { static void Main(string[] args) { Console.WriteLine("Hello C#.NET"); } } }</code></pre>
B. <pre><code class="csharp">using System; namespace IndiabixConsoleApplication { class MyProgram { static void Main(string[ ] args) { WriteLine("Hello C#.NET"); } } }</code></pre>
C. <pre><code class="csharp">using System.Console; namespace IndiabixConsoleApplication { class MyProgram { static void Main (string[ ] args) { WriteLine("Hello C#.NET"); } } }</code></pre>
D. <pre><code class="csharp">using System; namespace IndiabixConsoleApplication { class MyProgram { static void Main(string[] args) { Console.WriteLine("Hello C#.NET"); } } }</code></pre>
Answer» E.
265.

If a base class and a derived class each include a member function with the same name, the member function of the derived class will be called by an object of the derived class

A. True
B. False
Answer» B. False
266.

The size of a derived class object is equal to the sum of sizes of data members in base class and the derived class.

A. True
B. False
Answer» B. False
267.

Private members of base class cannot be accessed by derived class member functions or objects of derived class.

A. True
B. False
Answer» B. False
268.

A class D can be derived from a class C, which is derived from a class B, which is derived from a class A.

A. True
B. False
Answer» B. False
269.

There is no multiple inheritance in C#.NET. That is, a class cannot be derived from multiple base classes.

A. True
B. False
Answer» B. False
270.

Creating a derived class from a base class requires fundamental changes to the base class.

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

An object of a derived class cannot access private members of base class.

A. True
B. False
Answer» B. False
272.

We can derive a class from a base class even if the base class's source code is not available.

A. True
B. False
Answer» B. False
273.

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

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
Answer» B. Bix1 method
275.

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 &lt; 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
Answer» D. 1 India B
276.

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
Answer» B. Derived1 class
277.

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.
Answer» E. The Array elements are guaranteed to be sorted.
278.

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

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

Which one of the following classes are present System.Collections.Generic namespace? Stack Tree SortedDictionary SortedArray

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

Which of the following CANNOT be used as an underlying datatype for an enum in C#.NET?

A. <i class="csharp-code">byte</i>
B. <i class="csharp-code">short</i>
C. <i class="csharp-code">float</i>
D. <i class="csharp-code">int</i>
Answer» D. <i class="csharp-code">int</i>
281.

Which of the following statements are correct? The signature of an indexer consists of the number and types of its formal parameters. Indexers are similar to properties except that their accessors take parameters. Accessors of interface indexers use modifiers. The type of an indexer and the type of its parameters must be at least as accessible as the indexer itself. An interface accessor contains a body.

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

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

A. <pre><code class="csharp">class Sample { public int Length { set { Length = value; } } }</code></pre>
B. <pre><code class="csharp">class Sample { int len; public int Length { get { return len; } set { len = value; } } }</code></pre>
C. <pre><code class="csharp">class Sample { int len; public int Length { WriteOnly set { len = value; } } }</code></pre>
D. <pre><code class="csharp">class Sample { int len; public int Length { set { len = value; } } }</code></pre>
Answer» E.
283.

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

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

Which of the following are valid .NET CLR JIT performance counters? 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

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

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

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

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. <pre><code class="csharp">if ((n&amp;16) == 16) Console.WriteLine("Fourth bit is ON");</code></pre>
B. <pre><code class="csharp">if ((n&amp;8) == 8) Console.WriteLine("Fourth bit is ON");</code></pre>
C. <pre><code class="csharp">if ((n ! 8) == 8) Console.WriteLine("Fourth bit is ON");</code></pre>
D. <pre><code class="csharp">if ((n ^ 8) == 8) Console.WriteLine("Fourth bit is ON");</code></pre>
E. <pre><code class="csharp">if ((n ~ 8) == 8) Console. WriteLine("Fourth bit is ON");</code></pre>
Answer» C. <pre><code class="csharp">if ((n ! 8) == 8) Console.WriteLine("Fourth bit is ON");</code></pre>
287.

What will be the output of the C#.NET code snippet given below? int num = 1, z = 5; if (!(num &lt;= 0)) Console.WriteLine( ++num + z++ + " " + ++z ); else Console.WriteLine( --num + z-- + " " + --z );

A. 5 6
B. 6 5
C. 6 6
D. 7 7
Answer» E.
288.

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
Answer» D. Compile Error
289.

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 } } } To define a variable of type enum color in Main(), we should use the statement, color c; . enum color being private it cannot be used in Main(). We must declare enum color as public to be able to use it outside the class Sample. To define a variable of type enum color in Main(), we should use the statement, Sample.color c; . We must declare private enum color outside the class to be able to use it in Main().

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

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

A. <pre><code class="csharp">using System.Windows.Forms; using CtrlChars = Microsoft.VisualBasic.ControlChars; MessageBox.Show("Wait for a" + CrLf + "miracle");</code></pre>
B. <pre><code class="csharp">using Microsoft.VisualBasic; using System.Windows.Forms; CtrlChars = ControlChars; MessageBox.Show("Wait for a" + CtrlChars.CrLf + "miracle");</code></pre>
C. <pre><code class="csharp">using Microsoft.VisualBasic; using System.Windows.Forms; CtrlChars = ControlChars; MessageBox.Show ("Wait for a" + CrLf + "miracle");</code></pre>
D. <pre><code class="csharp">using System.Windows.Forms; using CtrlChars = Microsoft.VisualBasic.ControlChars; MessageBox.Show("Wait for a" + CtrlChars.CrLf + "miracle");</code></pre>
Answer» E.
291.

A function can be used in an expression, whereas a subroutine cannot be.

A. True
B. False
Answer» B. False
292.

Can static procedures access instance data?

A. Yes
B. No
Answer» C.
293.

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
Answer» B. -3, 0, 1
294.

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

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

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

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

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.
Answer» D. A property has to be either read only or a write only.
297.

Which of the following keyword is used to overload user-defined types by defining static member functions?

A. <i class="csharp-code">op</i>
B. <i class="csharp-code">opoverload</i>
C. <i class="csharp-code">operator</i>
D. <i class="csharp-code">operatoroverload</i>
E. <i class="csharp-code">udoperator</i>
Answer» D. <i class="csharp-code">operatoroverload</i>
298.

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

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

Which of the following are NOT Relational operators in C#.NET? &gt;= != Not &lt;= &lt;&gt;=

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