exam questions

Exam 98-361 All Questions

View all questions & answers for the 98-361 exam

Exam 98-361 topic 1 question 52 discussion

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

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

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
Difdoor
Highly Voted 3 years, 5 months ago
Answer B seems more appropriate. The question states how should you access the "Truck class" implementation of the brake() method. MyBase.brake() would access Vehicle.brake().
upvoted 11 times
JamieS
1 year, 1 month ago
I agree with this, it states the "Truck class" implementation, calling MyBase.brake or base.Brake would call the Vehicle class' implementation of brake.
upvoted 1 times
...
Hashino
2 years, 11 months ago
actually you can call "base.Brake()" inside Truck
upvoted 3 times
Hashino
2 years, 11 months ago
nvm, read the question wrong. in overriden methods called in the derived class that overrode the method this.break() calls the implementation of the derived class base.break() calls the implementations of the base class
upvoted 2 times
...
...
...
rbishun
Most Recent 6 months, 3 weeks ago
C. this.Brake() is the best answer. -------------------------------- class Vehicle { protected string Brake() { return "Breaking..."; } } class Truck : Vehicle { public string DoTruckWork() { return this.Brake(); } } static void DoTruck() { Truck truck = new(); Console.WriteLine(truck.DoTruckWork()); } --------------------------------
upvoted 1 times
...
[Removed]
8 months, 3 weeks ago
comming from c#, with base.Break(); would it be more fitting
upvoted 1 times
...
Heicke
1 year, 4 months ago
"...How should you call the Truck class implementation of the brake () method?" As far as I understood it you need to call the .Break() over a new instance of Truck. Truck does not have a declaration of Break to be called.
upvoted 1 times
...
KinC
1 year, 5 months ago
It's Truck.base()
upvoted 1 times
...
ccoutinho
2 years, 9 months ago
Is this VB.NET? I am a bit confused with this question
upvoted 4 times
JoelChuca
2 years, 2 months ago
Yes, this is in VB.Net https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/program-structure/me-my-mybase-and-myclass
upvoted 2 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 ...