C# Brain Bench Question

Question : C# Brain Bench Question

The answer to the queston below is number 1:

1) The DVD class declaration is wrong; you must specify the class first then any interfaces.

Is it right to say then this would be an acceptable declaration:

public class DVD : Media,  IMovie    ??

public abstract class Media
{
public abstract byte[ Read();
public abstract byte[ Read(long numBytes);
public abstract void Write(byte[ data);
}

public interface IMovie
{
string Title { get; set; }
int Zone { get; set; }
}

public class DVD : IMovie, Media
{
// implementation details
}

What is WRONG with the sample above?
Choice 1. The DVD class declaration is wrong; you must specify the class first then any interfaces.
Choice 2. C# does not support multiple inheritance.
Choice 3. You must declare the interface as static when using multiple inheritance.
Choice 4. You cannot mix interfaces and classes when using multiple inheritance.
Choice 5. You cannot use multiple inheritance when an abstract class is involved.


 

Solution :C# Brain Bench Question

You extend an abstract class or normal class (if there are any), then add any interfaces. And remember you can only extend ONE class but you can implement any number of interfaces.

Valid:
Class: Class
Class: Class, Interface
Class: Interface, Interface

Invalid:
Class: Interface, Class
Class: Class, Class