exam questions

Exam 98-361 All Questions

View all questions & answers for the 98-361 exam

Exam 98-361 topic 1 question 75 discussion

Actual exam question from Microsoft's 98-361
Question #: 75
Topic #: 1
[All 98-361 Questions]

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();
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Django
Highly Voted 3 years, 3 months ago
should be this.break()
upvoted 16 times
...
abdaziz
Most Recent 3 weeks, 2 days ago
the answer is this.break()
upvoted 1 times
...
KinC
11 months ago
It's Glass.break()
upvoted 1 times
JamieS
7 months, 2 weeks ago
No it's not, static methods can't be overloaded. It wants the derived version calling so this.break();
upvoted 2 times
...
...
seanbourg
11 months, 1 week ago
From the dotnet language specification / classes: "An override declaration can access the overridden base method using a base_access (Base access). In the example the base.PrintFields() invocation in B invokes the PrintFields method declared in A." Should be base.break() if you want to explicitly call the parent classes method - this.break() would work but could be overloaded if the base break() method isn't denoted as final.
upvoted 2 times
...
oneup
1 year, 2 months ago
It should be base.break() because Window inherits from Glass and you should call the Glass class implementation of the break() method. this.break() would call the Window implementation of the break() method. The first two answers are stupid because these would only be valid if the methods were static as the method name is prefixed by the class name and the question states that the methods are 'protected' and the question doesn't contain the keyword 'static'.
upvoted 1 times
matt11
11 months, 2 weeks ago
you're wrong - read the question again. The question says Glass inherits from Window (weirdly), so Glass is the derived class, not the base class.
upvoted 2 times
...
oneup
1 year, 2 months ago
And I also read it wrong as I thought Window inherits from Glass (feels logical as windows are made of glass and glasses aren't made of windows) but it's the other way around :)
upvoted 2 times
...
...
spotty
1 year, 4 months ago
This keeps being propagated in exam test prep questions. this and base are the C# keywords for accessing the derived and base class implementations. Windows and Glass are the class name. I thought maybe if they were static methods but static cant be virtual. There is another question which uses MyBase and This and a Vehicle/Truck analogy but it to is also wrong.
upvoted 4 times
...
musado
2 years, 6 months ago
this.break() and base.break()
upvoted 2 times
Hashino
2 years, 4 months ago
i'd say base.break(); is the better approach because the question specifically asks for the base class version of the method, and if the method was overridden this.break(); would call the overridden version instead
upvoted 2 times
Hashino
2 years, 4 months ago
again i read it wrong. this.brake() for the Glass implementation (derived class) base.brake() for the Window implementation (base class)
upvoted 9 times
...
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago