Quiz Yourself: Classes and OOP II
Assess your understanding of inheritance, polymorphism, casting, and static members in C#.
We'll cover the following...
We'll cover the following...
Technical Quiz
1.
We have a generic class public class Garage<T> where T : Vehicle. If we define class SUV : Car and class Car : Vehicle, is var myGarage = new Garage<SUV>(5); valid code?
A.
Yes, it is valid because inheritance is transitive.
B.
No, because SUV does not inherit directly from Vehicle.
C.
No, because the constraint requires T to be the exact type Vehicle.
D.
Yes, but only if SUV also explicitly implements a specific interface.
1 / 12
...