ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 73 - MB-820 discussion

Report
Export

You need to create the access modifier for IssueTotal.

Which variable declaration should you use?

A.

Protected vat IssueTotal: Decimal

Answers
A.

Protected vat IssueTotal: Decimal

B.

Internal var IssueTotal: Decimal

Answers
B.

Internal var IssueTotal: Decimal

C.

Public var IssueTotal: Decimal

Answers
C.

Public var IssueTotal: Decimal

D.

Local var IssueTotal: Decimal

Answers
D.

Local var IssueTotal: Decimal

E.

Var IssueTotal; Decimal

Answers
E.

Var IssueTotal; Decimal

Suggested answer: B

Explanation:

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

DRAG DROP:

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.

asked 13/10/2024
Phillip Roos
49 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first