Software Development Fundamentals — Question 3
You have a class named Glass that inherits from a base class named Window. The Window class includes a protected method named break().
How should you call the Glass class implementation of the break() method?
Answer options
- A. Window.break();
- B. Glass.break();
- C. this.break();
- D. base.break();
Correct answer: A
Explanation
The correct answer is A, as you need to call the method from the base class Window to invoke the original implementation. Option B is incorrect because Glass cannot directly call a method from itself without an instance. Option C is incorrect since 'this' refers to the current instance and would call the overridden method in Glass rather than the base method. Option D is also incorrect because 'base' is not a valid keyword in this context.