Search⌘ K
AI Features

Quiz Yourself: Classes and OOP

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

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

A developer writes the following code:

struct Vector { public int x; public int y; }
Vector v;
Console.WriteLine(v.x);

Why does this result in a compile-time error?

A.

Structs cannot be created without the new operator.

B.

Fields in a struct are private by default and cannot be accessed.

C.

The variable v is uninitialized, violating definite assignment rules.

D.

The default constructor was removed because no custom constructor exists.


1 / 14
...