Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Microsoft MB-820 Exam - Topic 4 Question 46 Discussion

You need to create the access modifier for IssueTotal.Which variable declaration should you use?
B) Internal var IssueTotal: Decimal
A) Protected vat IssueTotal: Decimal
C) Public var IssueTotal: Decimal
D) Local var IssueTotal: Decimal
E) Var IssueTotal; Decimal

Microsoft MB-820 Exam - Topic 4 Question 46 Discussion

Actual exam question for Microsoft's MB-820 exam
Question #: 46
Topic #: 4
[All MB-820 Questions]

You need to create the access modifier for IssueTotal.

Which variable declaration should you use?

Show Suggested Answer Hide Answer
Suggested Answer: B

In Business Central development using AL (the language for Business Central extensions), the use of access modifiers defines how variables and procedures are accessed within and outside of an object or codeunit.

Access Modifiers in AL:

Public: A public variable can be accessed from any object or codeunit within the same module or extension.

Protected: This restricts access to the current object and objects that inherit from the current object. However, in AL (at least in versions used for Business Central), the Protected access modifier is used with methods but not variables.

Internal: This modifier restricts the visibility to the current extension. This means that variables or methods declared as internal can only be accessed from within the same extension. This is appropriate when you want to provide functionality that is shared within the extension but not exposed externally.

Local: This restricts the variable or method to the current object or method where it is declared. It cannot be accessed from anywhere else, even within the same extension.

Scenario Justification:

In the scenario for Contoso, Ltd., IssueTotal is a global variable in the ISSUE BASE extension, and the ISSUE EXT extension needs to access it. Therefore, the variable cannot be declared as Local, because this would restrict access to just the current object (or method).

Using Public would expose the variable outside of the extension, which is unnecessary because you only want other parts of the extension (specifically the ISSUE EXT extension) to have access.

The best choice in this case is Internal because it restricts access to the variable to within the same extension, which includes the base extension and any dependent extensions like ISSUE EXT. It strikes the right balance between visibility and encapsulation.

Microsoft Dynamics 365 Business Central Developer Reference:

Access Modifiers in AL: Microsoft's documentation on AL provides the details on access modifiers, where it is specified that internal variables can be accessed within the extension, and the public variable is accessible across all extensionssource: Microsoft Learn on AL Programming.

Best Practices for AL Development: Business Central development best practices suggest keeping variables internal unless they need to be accessed outside of the current extensionsource: Microsoft Learn on AL development guidelines.


Contribute your Thoughts:

0/2000 characters
Jettie
5 days ago
I agree, C makes it accessible everywhere.
upvoted 0 times
...
Lai
10 days ago
I think C is the best choice. Public access is essential.
upvoted 0 times
...
Cletus
15 days ago
Wait, is D even a valid option?
upvoted 0 times
...
Filiberto
20 days ago
I’d go with B for internal use.
upvoted 0 times
...
Luis
25 days ago
Public makes sense, but is it really necessary?
upvoted 0 times
...
Kristin
1 month ago
A seems too restrictive for this case.
upvoted 0 times
...
Felicidad
1 month ago
I think C is the best choice for access.
upvoted 0 times
...
Sommer
1 month ago
"Local" doesn't seem right since it usually refers to variables within a method, but I can't remember if "var" is even a valid declaration here.
upvoted 0 times
...
Jody
3 months ago
I feel like "internal" might be the right choice since it limits access to the same assembly, but I could be mixing it up with another concept.
upvoted 0 times
...
Lynelle
3 months ago
I practiced a similar question where "public" was the right answer for broader access, but I can't recall if that's the case for this one too.
upvoted 0 times
...
Leslie
3 months ago
I think I remember that "protected" allows access within the same class and subclasses, but I'm not sure if that's the best choice here.
upvoted 0 times
...

Save Cancel