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?
A.
Window.break();
B.
Glass.break();
C.
this.break();
D.
base.break();
Should be C: this.break();
I think B is correct. Because you are going to call the Glass class. Not call the break function inside Glass.
The Correct answer is C. this.break();
because method break() are inherited from Windows class which is the base..
CMIIW..
Tested:
public class Window
{
protected int Break()
{
return 0;
}
}
public class Glass :Window
{
public void foo() {
this.Break();
}
}
Answer: this.Break();
Answer: this.Break();
“Glass.break()” Would be for a static method.
Depends from where called (mind you, questions states ‘how would you call the Glass implementation of the Break method’, not how would you implement it within Glass class).
Either way…
From Glass class = this.Break
From Glass instance = cGlass.Break (Glass.Break is static syntax)
Questions are hard to decipher, …as are the answer options???