Multiple choice

Which of the following is the best method of accessing a method of the base class in C#?

  1. Declare the method outside the base class only.

  2. Declare the method in the derived class only.

  3. Declare the method in both base class and derived class.

  4. Declare the method in the base class with the keyword 'Hide'.

  5. Delete the method declared in base and derived class.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

This is the correct option as the method is declared in both base and derived class by default the derived version of the method is only accessible but to access the base class method the following changes has to be done in the program. DerivedClass test = new DerivedClass();  ((BaseClass)test).TestMethod();   The above code will only access the base class method of a class.