nerdexam
Microsoft

MB-500 · Question #246

Drag and Drop Question A company uses Dynamics 365 Finance. You must implement three classes with the following requirements: - Variables in ClassA must be accessible from ClassA and its child…

The correct answer is ClassA: Protected; ClassC: Private. X++ Variable Modifiers - Explanation The Three Modifiers | Modifier | Accessible From | |---|---| | public | Any class, anywhere | | protected | The class itself + all child (subclass) classes | | private | Only the class itself - nobody else | --- Placement 1: ClassA →…

Design and develop AOT elements

Question

Drag and Drop Question A company uses Dynamics 365 Finance. You must implement three classes with the following requirements: - Variables in ClassA must be accessible from ClassA and its child classes but not from other classes. ClassB is a class that inherits from ClassA. - ClassC is not a parent or child class of any other class. The variables of ClassC must only be accessible within ClassC. You need to complete the implementation. Which variable modifiers should you use? To answer, drag the appropriate variable modifiers to the correct class names. Each variable modifier may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content. NOTE: Each correct selection is worth one point. Answer:

Exhibit

MB-500 question #246 exhibit

Answer Area

Drag items

ProtectedPrivatePublic

Correct arrangement

  • ClassA: Protected
  • ClassC: Private

Explanation

X++ Variable Modifiers - Explanation

The Three Modifiers

ModifierAccessible From
publicAny class, anywhere
protectedThe class itself + all child (subclass) classes
privateOnly the class itself - nobody else

Placement 1: ClassA → Protected

Requirement: Variables must be accessible from ClassA and its child classes, but not from unrelated classes.

This is precisely what protected does. ClassB inherits from ClassA, so protected variables on ClassA are visible inside ClassB automatically - no separate declaration needed for ClassB. Using public would fail because it would expose the variables to every class, violating the "not from other classes" constraint. Using private would fail because ClassB (a child) couldn't access them.


Placement 2: ClassC → Private

Requirement: Variables must only be accessible within ClassC itself.

This is precisely what private does - it locks access to the declaring class only. Since ClassC has no parent or child relationship, there's nothing to inherit to or from, making private the correct and only appropriate choice.


Why ClassB Has No Answer

ClassB is not listed as requiring its own variable modifier. It's a consumer of ClassA's protected variables, not a source of new access-controlled variables in this scenario.


Common Misconceptions

  • Confusing protected with private: A common mistake is thinking "restricted = private," but protected is the right "restricted-but-inheritable" choice.
  • Using public for ClassA: Public satisfies the "child class can access it" part but breaks the "not from other classes" requirement.
  • Thinking ClassB needs an answer: ClassB inherits; it doesn't redeclare. The question is about where variables are defined, not where they're used.

Topics

#access modifiers#X++ classes#inheritance#encapsulation

Community Discussion

No community discussion yet for this question.

Full MB-500 Practice