CommerceClasses And Objects In C Sharp MCQs
Practice Classes And Objects In C Sharp MCQs for competitive exams.
Classes And Objects In C Sharp MCQs
Practice questions from this topic.
In C#, what is the keyword used to create a reference to the current instance of a class?
- A. self
- B. current
- C. instance
- D. this
Correct Answer: D
What is the access modifier used to declare a class member that is accessible only within its own class in C#?
- A. internal
- B. protected
- C. private
- D. public
Correct Answer: C
In C#, what is the process of defining a new class within another class called?
- A. Inner Class
- B. Subclass
- C. Parent Class
- D. Nested Class
Correct Answer: D
What is the keyword used to create an alias for a data type in C#?
- A. using
- B. typedef
- C. alias
- D. class
Correct Answer: C
In C#, which method is automatically called when an object is created to initialize the object's state?
- A. Instantiate
- B. Initialize
- C. Constructor
- D. Destructor
Correct Answer: C
What is the concept in OOP that allows a class to have more than one method with the same name but different parameters in C#?
- A. Inheritance
- B. Method Overloading
- C. Encapsulation
- D. None of the above
Correct Answer: B
In C#, what is the keyword used to explicitly call a base class constructor from a derived class constructor?
- A. parent
- B. this.base
- C. base
- D. super
Correct Answer: C
What is the process of creating a new class based on an existing class in C# called?
- A. Abstraction
- B. Polymorphism
- C. Encapsulation
- D. Inheritance
Correct Answer: D
In C#, what is the method called automatically when an object is no longer in use and is being destroyed?
- A. Destructor
- B. Finalizer
- C. Dispose
- D. Garbage Collector
Correct Answer: C
What is the purpose of the readonly keyword when applied to a field in a class in C#?
- A. To indicate that the field's value can only be set once
- B. To indicate that the field's value cannot be changed
- C. To indicate that the field's value is constant
- D. To indicate that the field's value is null
Correct Answer: A
What is the default access modifier for class members in C# if no access modifier is specified?
- A. public
- B. protected
- C. internal
- D. private
Correct Answer: D
In C#, which keyword is used to declare a class member that can only be accessed within its own class and derived classes?
- A. internal
- B. protected
- C. protected internal
- D. private internal
Correct Answer: C