Recall & Review
beginner
What does the
base keyword do in C#?The <code>base</code> keyword lets a derived class access members (methods, properties, constructors) of its base class. It helps call or refer to the base class version of a member.Click to reveal answer
beginner
How do you use <code>base</code> to call a base class constructor?You use <code>base(arguments)</code> in the derived class constructor's initializer to call a specific base class constructor before running the derived constructor's body.Click to reveal answer
intermediate
Can
base be used to access overridden methods?Yes. Inside an overridden method, <code>base.MethodName()</code> calls the base class version of that method, bypassing the override.Click to reveal answer
beginner
What happens if you don't use
base when overriding a method?If you don't use <code>base</code>, the derived class method completely replaces the base class method. The base method is not called unless explicitly invoked with <code>base</code>.Click to reveal answer
intermediate
Can <code>base</code> be used to access base class fields directly?No. <code>base</code> cannot be used to access base class fields directly if they are private. It works with accessible members like protected or public fields, properties, and methods.Click to reveal answer
What is the purpose of the
base keyword in C#?✗ Incorrect
The
base keyword is used to access members of the base class from within a derived class.How do you call a base class constructor with parameters from a derived class?
✗ Incorrect
You call a base class constructor by using
base(parameters) in the derived class constructor's initializer.Inside an overridden method, how do you call the base class version of that method?
✗ Incorrect
You use
base.MethodName() to call the base class version of an overridden method.Can
base be used to access private fields of the base class?✗ Incorrect
Private fields are not accessible from derived classes, even with
base.What happens if you override a method but do not call
base.Method() inside it?✗ Incorrect
If you don't call
base.Method(), the base method is not executed when the override runs.Explain how the
base keyword helps when overriding methods in C#.Think about how to run the original method from the base class when you have a new version in the derived class.
You got /3 concepts.
Describe how to use
base to call a base class constructor from a derived class constructor.Remember the syntax after the colon in the derived constructor.
You got /3 concepts.