MB6-704 · Question #40
You have the following X++ code: (Line numbers are included for reference only.) Methodl and method2 are in Classl. Method3 is in Class2. You need to ensure that you can change the value of vanable2…
The correct answer is B. Create a public accessor method for vanable2. All classes are public, but all member variables are implicitly private. Use a public Setter Accessor method to change a variable of the other class. Add a Setter Accessor Method Follow these steps to add a method that sets the value of a member variable: 1. Right-click the…
Question
You have the following X++ code: (Line numbers are included for reference only.) Methodl and method2 are in Classl. Method3 is in Class2. You need to ensure that you can change the value of vanable2 at line 21. What should you do first?
Exhibit
Options
- ACreate a protected access or method for variable2.
- BCreate a public accessor method for vanable2.
- CDeclare variable2 as a public variable.
- DDeclare variable2 as a protected variable.
How the community answered
(53 responses)- A8% (4)
- B85% (45)
- C2% (1)
- D6% (3)
Explanation
All classes are public, but all member variables are implicitly private. Use a public Setter Accessor method to change a variable of the other class. Add a Setter Accessor Method Follow these steps to add a method that sets the value of a member variable: 1. Right-click the Class1 node, and then click New > Method. 2. Rename the method1 node to setFirstName. 3. In the code Editor window, paste in the following X++ code for the method. public void setFirstName(str _firstName) firstName = _firstName;
Topics
Community Discussion
No community discussion yet for this question.
