nerdexam
Microsoft

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…

Develop X++ code

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

MB6-704 question #40 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)
  • A
    8% (4)
  • B
    85% (45)
  • C
    2% (1)
  • D
    6% (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

#access modifiers#accessor methods#class variables#encapsulation

Community Discussion

No community discussion yet for this question.

Full MB6-704 Practice