nerdexam
Microsoft

MB6-704 · Question #88

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 set variablel for classlObj to a value of 5…

The correct answer is A. classl0bj.methodl(5). All classes are public, but all member variables are implicitly private. Use a public Setter Accessor method, here method1, on Obj1 to change the variable of the other class. Add a Setter Accessor Method Follow these steps to add a method that sets the value of a member…

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 set variablel for classlObj to a value of 5. Which code segment should you insert at line 21?

Exhibit

MB6-704 question #88 exhibit

Options

  • Aclassl0bj.methodl(5);
  • Bnew Classl().methodl(5);
  • CclasslObj.variable1= 5;
  • Dthis.variablel =5:

How the community answered

(32 responses)
  • A
    72% (23)
  • B
    13% (4)
  • C
    6% (2)
  • D
    9% (3)

Explanation

All classes are public, but all member variables are implicitly private. Use a public Setter Accessor method, here method1, on Obj1 to change the 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

#X++ methods#variable access#class instances#encapsulation

Community Discussion

No community discussion yet for this question.

Full MB6-704 Practice