C# - Classes and Objects Questions and Answers
Practice ModeShowing 10 of 37 questions
Q11
Which of the following statements are correct about objects of a user-defined class called Sample?
All objects of Sample class will always have exactly same data.
Objects of Sample class may have same or different data.
Whether objects of Sample class will have same or different data depends upon a Project Setting made in Visual Studio.NET.
Conceptually, each object of Sample class will have instance data and instance member functions of the Sample class.
All objects of Sample class will share one copy of member functions.
Answer: Option C
Q12
Which of the following statements is correct about classes and objects in C#.NET?
Answer: Option
Q13
Which keyword is used to define a class in C#?
Answer: Option B
Explanation: Classes in C# are declared using the class keyword.
Q14
What is an instance of a class called?
Answer: Option A
Explanation: Objects are runtime instances of classes.
Q15
Which access modifier allows members to be visible only within the same class?
Answer: Option B
Explanation: Private members are accessible only within the class itself.
Q16
What is the entry point method for a C# program?
Answer: Option C
Explanation: The Main() method is the starting point of execution.
Q17
Which keyword is used to create an object in C#?
Answer: Option C
Explanation: The new keyword instantiates a class.
Q18
What is the default access modifier for class members in C#?
Answer: Option C
Explanation: Members inside a class are private unless otherwise specified.
Q19
Which of the following can be used to initialize class variables during object creation?
Answer: Option B
Explanation: Constructors run automatically when an object is created.
Q20
What happens if no constructor is defined in a class?
Answer: Option B
Explanation: C# creates an implicit parameterless constructor.