exam questions

Exam MB-500 All Questions

View all questions & answers for the MB-500 exam

Exam MB-500 topic 4 question 1 discussion

Actual exam question from Microsoft's MB-500
Question #: 1
Topic #: 4
[All MB-500 Questions]

HOTSPOT -
You are a Dynamics 365 Finance developer. You have the following code: (Line numbers are created for reference only.)

Which values does the info() method return? To answer, select the appropriate option in the answer area.
NOTE: Each correct selection is worth one point.
Hot Area:

Show Suggested Answer Hide Answer
Suggested Answer:
Box 1: SID1234 -

Parameters -
All methods have their own scope. A method can take one or more parameters. Within the scope of the method, these parameters are treated as local variables and are initialized with a value from the parameter in the method call. All parameters are passed by value, which means that you can't change the value of the original variable. You can change only the local variable in the method. This local variable is a copy of the original variable.

Box 2: 5 -
Reference:
https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/dev-ref/xpp-classes-methods

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
Anton_Venter
Highly Voted 4 years, 2 months ago
SID1234-Updated 5 The table buffer is a reference so it keeps the udpated values. The SalesQty is dereferenced by the conversion to string method. I tested this and found two compile errors on line 17 and 22.
upvoted 35 times
globeearth
2 weeks ago
Agreed
upvoted 1 times
...
sertan
3 years, 6 months ago
Correct, see for yourself : class RunnableClass1 { public static void main(Args _args) { RunnableClass1 rn = new RunnableClass1(); rn.run(); } public void run() { TmpFrmVirtual tmpFrmVirtual; tmpFrmVirtual.Id = "test"; this.update(tmpFrmVirtual); Info(tmpFrmVirtual.Id); } public void update(TmpFrmVirtual _tmp) { TmpFrmVirtual tmp = _tmp; tmp.Id = "Updated"; } }
upvoted 3 times
...
...
ihoril
Most Recent 6 months, 4 weeks ago
The following code: public static void main(Args _args) { RunnableClass1 test =new RunnableClass1(); test.run(); } public void run() { SalesTable salesTable; int salesQty = 5; salesTable.SalesId = 'SO1234'; this.updateValues(salesTable,salesQty); info(salesTable.SalesId); info(int2Str(salesQty)); } public void updateValues(SalesTable _salesTable, int _salesQty) { SalesTable salesTable = _salesTable; salesTable.SalesId = 'SO1234-Updated'; _salesQty = 10; } Returns result as SO1234-Updated 5
upvoted 1 times
...
theCoder1
1 year, 10 months ago
SID1234-Updated 5 by ChatGPT
upvoted 2 times
...
Mohammed_Talha
1 year, 10 months ago
they didnt write tmpFrmVirtual.update(); that's why answer is correct
upvoted 1 times
kself
1 year, 4 months ago
The updateValues function creates a local variable for the table that is a reference to the parameter (not a copy)...any changes made to the local variable are reflected on the original buffer. The run method does not attempt to re-read from the tmpFrmVirtual buffer after calling updateValues, so calling 'update' on the buffer does not matter for this example.
upvoted 1 times
...
...
gverstrepen
3 years, 1 month ago
Disregarding the fact that the given code wouldn't even compile... The output would be : 1) TmpFrmVirtual.Id ==> SID1234-Updated 2) salesQty ==> 5 As stated earlier by others : ------------------------------------------- 1) TmpFrmVirtual is a table buffer, and is always passed as a reference (i.e. as a pointer to the original table buffer, NOT as a COPY of the original table buffer). So any changes to the buffer made in the updateValues() method are actually made to the original buffer in the run() method. 2) The salesQty variable, on the other hand, is converted to and passed as a String, then converted back to integer. This means that we're are actually modifying the value of a COPY of the original variable, NOT the value of the original variable itself. Also the COPY of the original value only exists while executing the updateValues() method and it's value is never returned to the run() method. Hence the value of the salesQty variable in the run() method remaines unchanged.
upvoted 2 times
gverstrepen
3 years, 1 month ago
for the non-believers : copy/paste the code below into a runable class and check the output yourself... static void TestD35ExamQuestion(Args _args) { TmpFrmVirtual tmpFrmVirtual; int salesQty = 5; void updateValues(TmpFrmVirtual _tmpFrmVirtual, str _salesQty) { TmpFrmVirtual tmpLocalFrmVirtual = _tmpFrmVirtual; int localSalesQty = str2int(_salesQty); tmpLocalFrmVirtual.Id = 'SID1234-Updated'; localSalesQty = 10; } void run() { tmpFrmVirtual.Id = 'SID1234'; // Call the updateValues method updateValues(tmpFrmVirtual, int2str(salesQty)); info(tmpFrmVirtual.Id); info(strFmt('%1',salesQty)); } // Execute the run method run(); }
upvoted 1 times
...
...
Prollyx
3 years, 2 months ago
SID1234-Updated 5 Table buffer is passed as reference, int as a value
upvoted 3 times
...
faycal
3 years, 5 months ago
SID1234 5
upvoted 3 times
...
Rolf_the_magnificent
3 years, 6 months ago
The Update method never touches the original objects... Output is the original input
upvoted 2 times
...
m463r
3 years, 10 months ago
Invalid codes info(salesQty); //error due to salesQty is an int int salesQty = _str2int(salesQty); //error, no _str2int and it should be _salesQty tmpFrmVirtual.Id = "SID1234"-Updated"; //error, wrong placement of double quotes If those errors were fixed the answers should be SID1234-Updated 5
upvoted 3 times
...
viking1
3 years, 11 months ago
SID1234-Updated 5 The table buffer is, as pointed out below, a reference, so any changes made to the buffer referenced by one variable are also visible in any other variables referencing the same buffer. There is no need for transactions or update()/doUpdate() for this.
upvoted 1 times
...
axdev1
3 years, 11 months ago
The answer is correct. In updateValues method transaction is missing: ttsBegin; tmpFrmVirtual.doUpdate.Id = "SID1234-Updated"; salesQty = 10; tmpFrmVirtual.doUpdate(); ttsCommit;
upvoted 1 times
...
homerzhang
4 years ago
the answer is correct. SID1234 5 in my mind , the table buffer is pass by reference, but the result is really different. I run it in visual studio, the answer is right. if you don't belive me, please just try the code in visual studio.
upvoted 4 times
...
Rahul_01
4 years ago
First parameter is pass by reference, Second is pass by Value. Answer: SID-1234-Updates, 5
upvoted 4 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 ...