115
77.8k

150+ C# Programming Solved MCQs

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Computer Science Engineering (CSE) , Information Technology Engineering (IT) , Master of Computer Applications (MCA) , Programming Languages .

Chapters

Chapter: Unit 2
51.

Which of the following statements is correct about constructors?

A. If we provide a one-argument constructor then the compiler still provides a zeroargument constructor.
B. Overloaded constructors have the same name as the class name
C. Overloaded constructors cannot use optional arguments.
D. If we do not provide a constructor, then the compiler provides a zero-argument constructor.
Answer» D. If we do not provide a constructor, then the compiler provides a zero-argument constructor.
52.

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.
C. An object is destroyed by the garbage collector when only one reference refers to it.
D. We have to specifically run the garbage collector after executing Visual Studio.NET.
Answer» B. There is one common garbage collector for all programs.
53.

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

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

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.
Answer» D. The default value of numeric array elements is zero.
55.

Which of the following statements are correct about arrays used in C#.NET?
1. Arrays can be rectangular or jagged.
2. Rectangular arrays have similar rows stored in adjacent memory locations.
3. Jagged arrays do not have an access to the methods of System.Array Class.
4. Rectangular arrays do not have an access to the methods of System.Array Class.
5. 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
Answer» D. 1,2,5
56.

Which of the following statements are correct?
1. A struct can contain properties.
2. A struct can contain constructors.
3. A struct can contain protected data members.
4. A struct cannot contain methods.
5. A struct cannot contain constants.

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

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
B. CRE
C. CR
D. REA
Answer» B. CRE
58.

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. s1.Equals(s2)
Answer» D. s1.Equals(s2)
59.

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.
Answer» C. It occurs at run-time.
60.

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 cleanup operations like closing the network/database connections.

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

______ parameters are used to pass results back to the calling method.

A. Input
B. Reference
C. Value
D. Output
Answer» D. Output
62.

The formal-parameter-list is always enclosed in _______.

A. Square
B. Semicolon
C. Parenthesis
D. Colon
Answer» C. Parenthesis
63.

_______ variables are visible only in the block they are declared.

A. System
B. Global
C. Local
D. Console
Answer» C. Local
64.

C# does not support _____ constructors.

A. parameterized
B. parameter-less
C. Class
D. Method
Answer» B. parameter-less
65.

A structure in C# provides a unique way of packing together data of ______ types.

A. Different
B. Same
C. Invoking
D. Calling
Answer» A. Different
66.

Struct’s data members are ____________ by default.

A. Protected
B. Public
C. Private
D. Default
Answer» C. Private
67.

A _______ creates an object by copying variables from another object.

A. Copy constructor
B. Default constructor
C. Invoking constructor
D. Calling constructor
Answer» A. Copy constructor
68.

The methods that have the same name, but different parameter lists and different definitions is called______.

A. Method Overloading
B. Method Overriding
C. Method Overwriting
D. Method Overreading
Answer» A. Method Overloading
69.

The C# provides special methods known as _____ methods to provide access to data members.

A. Loop
B. Functions
C. Methods
D. Accessor
Answer» D. Accessor
70.

Storage location used by computer memory to store data for usage by an application is ?

A. Pointers
B. Constants
C. Variable
D. None of the mentioned
Answer» C. Variable
71.

Which of these can be overloaded?

A. Constructors
B. Methods
C. Both a & b
D. None of the mentioned
Answer» C. Both a & b
72.

Number of constructors a class can define of ?

A. 1
B. 2
C. Any number
D. None of the mentioned
Answer» C. Any number
73.

Correct statement about constructors in C#.NET is ?

A. Constructor cannot be overloaded
B. Constructor allocate space for object in memory
C. Constructor are never called explicitly
D. Constructor have same name as name of the class
Answer» D. Constructor have same name as name of the class
74.

Constructors are used to

A. initialize the objects
B. construct the data members
C. both a & b
D. None of the mentioned
Answer» C. both a & b
75.

To overload a method which of the following statement is false?

A. If the return type is different methods are overloaded
B. Name of the overloaded method should be same
C. Type of the parameter should be different
D. Order of the parameter should be different if types are same
Answer» A. If the return type is different methods are overloaded
76.

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. None of the mentioned
Answer» D. None of the mentioned
77.

What is return type of constructors?

A. int
B. float
C. void
D. None of the mentioned
Answer» D. None of the mentioned
78.

Which method have same name as that of its class?

A. delete
B. class
C. constructor
D. None of mentioned
Answer» C. constructor
79.

Which of following statement are correct about functions?

A. C# allows a function to have arguments with default values
B. Redefining a method parameter in the method’s body causes an exception
C. C# allows function to have arguments of private type
D. Omitting the return type in method definition results into exception
Answer» A. C# allows a function to have arguments with default values
Chapter: Unit 3
80.

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.

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

How many enumerators will exist if four threads are simultaneously working on an ArrayList object?

A. 1
B. 3
C. 2
D. 4
Answer» D. 4
82.

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

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

Which of the following statements are correct about the Stack collection?
1. It can be used for evaluation of expressions.
2. All elements in the Stack collection can be accessed using an enumerator.
3. It is used to maintain a FIFO list.
4. All elements stored in a Stack collection must be of similar type.
5. 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
Answer» C. 1, 2 and 5 only
84.

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

A. IEnumerator e; e = q.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);
B. IEnumerable e; e = q.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);
C. IEnumerator e; e = q.GetEnumerable(); while (e.MoveNext()) Console.WriteLine(e.Current);
D. IEnumerator e; e = Queue.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);
Answer» A. IEnumerator e; e = q.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);
85.

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. Only one method can be called using a delegate.
Answer» D. Only one method can be called using a delegate.
86.

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.

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

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 comparison function?

A. Namespace
B. Interface
C. Encapsulation
D. Delegate
Answer» D. Delegate
88.

What is a delegate?

A. A strongly typed function pointer.
B. A light weight thread or process that can call a single method.
C. A reference to an object in a different process.
D. An inter-process message channel.
Answer» A. A strongly typed function pointer.
89.

Which of the following is included in Visual Studio IDE?

A. Form Designer
B. Code Editor
C. Solution Explorer
D. All of the above
Answer» D. All of the above
90.

Which of the following is true about dispose() method?

A. This method is protected.
B. Its return type is int.
C. It accepts a float parameter.
D. All of the above.
Answer» A. This method is protected.
91.

Button class derives from

A. Checkbox
B. RadioButton
C. ButtonBase
D. None of the above
Answer» C. ButtonBase
92.

Which namespace includes most of the Control classes for developing Windows applications?

A. System;
B. System.Windows.Controls
C. System.Windows.Components.Forms
D. System.Windows.Forms
Answer» C. System.Windows.Components.Forms
93.

Which of the Control objects is viewed as a container that can hold other objects when you design a Windows application?

A. Control
B. Button
C. Window
D. Form
Answer» D. Form
94.

When an instance method declaration includes the abstract modifier, the method is said to be an ______.

A. Abstract method
B. Instance method
C. Sealed method
D. Expression method
Answer» A. Abstract method
95.

The theory of _____ implies that user can control the access to a class, method, or variable.

A. Data hiding
B. Encapsulation
C. Information Hiding
D. Polymorphism
Answer» B. Encapsulation
96.

Inheritance is ______ in nature.

A. Commutative
B. Associative
C. Transitive
D. Iterative
Answer» C. Transitive
97.

The point at which an exception is thrown is called the _______.

A. Default point
B. Invoking point
C. Calling point
D. Throw point
Answer» D. Throw point
98.

In C#, having unreachable code is always an _____.

A. Method
B. Function
C. Error
D. Iterative
Answer» C. Error
99.

C# treats the multiple catch statements like cases in a _____________ statement.

A. If
B. Switch
C. For
D. While
Answer» B. Switch
100.

C# supports a technique known as________, which allows a method to specify explicitly the name of the interface it is implementing.

A. Method Implementation
B. Implicit Interface Implementation
C. Explicit Interface Implementation
D. Iterative Interface Implementation
Answer» C. Explicit Interface Implementation

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.