NEW
Font size
WorksheetsC# classes and objects
Total questions: 10
Worksheet time: 5mins
What is a class in C#?
a) A variable that stores data
b) A blueprint for creating objects
c) A method inside an object
d) A type of loop
A
B
C
D
Which keyword is used to create an object in C#?
a) this
b) new
c) object
d) create
A
B
C
D
Which of the following is TRUE about objects?
a) Objects are templates of classes
b) Objects occupy memory only at compile time
c) Objects are created from classes
d) Objects cannot access methods
A
B
C
D
Which of the following can a class contain?
a) Only methods
b) Only variables
c) Methods, properties, constructors
d) Only constructors
A
B
C
D
How do you access members of a class using an object?
a) Using => operator
b) Using :: operator
c) Using . (dot) operator
d) Using -> operator
A
B
C
D
What is the default access modifier for class members in C#?
a) public
b) private
c) protected
d) internal
A
B
C
D
Which of the following statements is TRUE about constructors?
a) Constructors must have a return type
b) Constructors have the same name as the class
c) Constructors are called manually
d) A class can have only one constructor
A
B
C
D
What happens if you do NOT write a constructor in your class?
a) Compilation error
b) Program will not run
c) C# provides a default constructor
d) Object cannot be created
A
B
C
D
Which keyword refers to the current object instance?
a) this
b) myself
c) base
d) self
A
B
C
D
What is object instantiation?
a) Declaring a variable of type int
b) Creating an instance of a class using the new keyword
c) Calling a static method
d) Writing a constructor
A
B
C
D
