Quiz Yourself: Classes and OOP

Assess your understanding of C# classes and object-oriented programming.

We'll cover the following...
Technical Quiz
1.

You define a class Robot that contains a single custom constructor: public Robot(string name) { ... }. You then attempt to instantiate it using var r = new Robot();. What happens?

A.

The compiler generates an error because the automatic default constructor is removed when a custom one is defined.

B.

The compiler automatically generates a parameterless constructor to resolve the call, creating a Robot with null fields.

C.

The code compiles, but the properties of the Robot instance remain uninitialized until accessed.

D.

The runtime throws a MissingMethodException because it cannot find an entry point for the instantiation.


1 / 14