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 syntax to define a constructor for a class named Car that takes parameters make and model?
- A. Car(string make, string model) { }
- B. Car = (string make, string model) => { }
- C. void Car(string make, string model) { }
- D. public Car(string make, string model) { }
Correct Answer: D
Which keyword is used to access members of a class from within the class itself in C#?
- A. current
- B. me
- C. this
- D. self
Correct Answer: C
What is the purpose of a constructor in C#?
- A. To define properties of a class
- B. To initialize the object's state
- C. To destroy the object
- D. None of the above
Correct Answer: B
What is the access specifier that allows members of a class to be accessed from any other class in the same assembly in C#?
- A. public
- B. private
- C. protected
- D. internal
Correct Answer: D
What is an object in C#?
- A. A method in C#
- B. A variable in C#
- C. An instance of a class
- D. A data type in C#
Correct Answer: C
Which keyword is used to create an object of a class in C#?
- A. create
- B. instance
- C. object
- D. new
Correct Answer: D
What is a class in C#?
- A. A blueprint for creating objects
- B. A method in C#
- C. A variable in C#
- D. A data type in C#
Correct Answer: A