You have a class named Truck that inherits from a base class named Vehicle. The Vehicle
class includes a protected method named brake ().
How should you call the Truck class implementation of the brake () method?
A.
Vehicle. brake ();
B.
This. brake ();
C.
MyBase. brake();
D.
Truck. brake ();
Explanation:
The MyBase keyword behaves like an object variable referring to the base class of the
current instance of a class.MyBase is commonly used to access base class members that
are overridden or shadowed in a derived class.
There is no such thing like a MyBase in c#.
Answer is D: Truck.brake();
protected members or methods are accessible within the class and derived calss.
public class Vehicle
{
private int a;
protected void Break()
{
{ Console.WriteLine(“Breaks from Vehicle”); }
}
}
class Truck : Vehicle
{
static void Main(string[] args)
{
Truck t = new Truck();
t.Break();
}
}
B.
This. brake ();
Answer is C. Mybase is used in VIsual Basic
https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/program-structure/me-my-mybase-and-myclass