Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam MCD - Level 1 All Questions

View all questions & answers for the MCD - Level 1 exam

Exam MCD - Level 1 topic 1 question 99 discussion

Actual exam question from Mulesoft's MCD - Level 1
Question #: 99
Topic #: 1
[All MCD - Level 1 Questions]

A Mule project contains a DataWeave module called MyModule.dwl that defines a function named formatString. The module is located in the project's src/main/ resources/modules folder.
What is the correct way in DataWeave code to import MyModule using a wildcard and then call the module's formatString function?
A.

B.

C.

D.

Show Suggested Answer Hide Answer
Suggested Answer: A
Reference:
https://docs.mulesoft.com/mule-runtime/4.2/dataweave-create-module

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
pgarciar
Highly Voted 3 years, 8 months ago
C is correct
upvoted 18 times
Zumo
3 years, 6 months ago
C is not the Correct Answer. Reference : https://docs.mulesoft.com/mule-runtime/4.3/dataweave-create-module#using-a-mapping-file-in-a-dataweave-script Example from above URL is as follows: %dw 2.0 import modules::MyMapping output application/json --- MyMapping::main(payload: { "user" : "bar" }) ----------------------- Correct Answer would be Option 'A'
upvoted 11 times
Damster_99
1 year, 2 months ago
C is the correct Answer. Tested in Anypoint Studio
upvoted 1 times
...
...
...
ck0241
Highly Voted 3 years, 4 months ago
C is the correct answer since we are importing myModule using wildcard.
upvoted 8 times
edilberto1
3 years, 3 months ago
Totally Agree, referring to above documentation (https://docs.mulesoft.com/mule-runtime/4.3/dataweave-create-module#using-a-mapping-file-in-a-dataweave-script), it said that if you import using the * setting the name front the function is not required, So Right Answer is C
upvoted 2 times
...
...
Krunchysoup
Most Recent 2 months, 1 week ago
C is correct. It's a catch all situation. Any other choice would be wrong based on process of elimination. A uses catch all so it shouldn't need to use MyModule::formatString. and C is the only one that imports correctly using ::
upvoted 1 times
...
kimbi
8 months, 2 weeks ago
Anser is A
upvoted 1 times
...
Alandt
9 months, 3 weeks ago
A is the correct answer, ignore my other comment.
upvoted 1 times
...
Alandt
9 months, 3 weeks ago
ChatGPT: The correct answer is Option C: This option correctly imports all functions from MyModule and allows you to call formatString directly, without needing to prefix it with the module name.
upvoted 1 times
...
Serjp3
10 months ago
"Import all elements from the module, for example: import * from modules::MyModule. In this case, you do not need to include the name of the module when you call the element. For example: myFunc("dataweave") ++ "name" works." - https://docs.mulesoft.com/dataweave/latest/dataweave-create-module
upvoted 1 times
...
ExamDev
10 months ago
A is the correct answer because they are talking about CUSTOM modules. !!!!!!! VERIFIED IN THE Anypoint Studio. (I was wrong with my previous post)
upvoted 1 times
Alandt
9 months, 3 weeks ago
That's what I thought too! thanks
upvoted 1 times
...
...
ExamDev
10 months, 1 week ago
C!!!!!
upvoted 1 times
...
Damster_99
1 year, 2 months ago
C is the correct Answer https://imgur.com/a/vK8L2CP Is the only flow that compiled without error and works.
upvoted 1 times
...
malakas1231
1 year, 3 months ago
A is correct. Look at this from official mulesoft docs: https://docs.mulesoft.com/dataweave/2.4/dw-functions "The way you import a module impacts the way you need to call its functions from a DataWeave script. If the directive does not list specific functions to import or use * from to import all functions from a function module, you need to specify the module when you call the function from your script. "
upvoted 1 times
...
Maddy_123
1 year, 8 months ago
C is correct. https://apisero.com/import-a-function-module-in-dataweave/
upvoted 2 times
...
BankZenith
2 years, 8 months ago
A is correct , mule soft trainer is answer me.
upvoted 2 times
...
frediepulgoso
2 years, 8 months ago
A is correct
upvoted 1 times
...
calazans
2 years, 10 months ago
C is correct https://docs.mulesoft.com/dataweave/2.2/dataweave-create-module There are several ways to import a module or elements in it: Import the module, for example: import modules::MyModule. In this case, you must include the name of the module when you call the element (here, a function) in it, for example: MyModule::myFunc. Import all elements from the module, for example: import * from modules::MyModule. In this case, you do not need to include the name of the module when you call the element. For example: myFunc("dataweave") ++ "name" works. Import specific elements from a module, for example: import myFunc from modules::MyModule. In this case, you do not need to include the name of the module when you call the element. For example: myFunc("dataweave") ++ "name" works. You can import multiple elements from the module like this, for example: import myFunc someOtherFunction from modules::MyModule (assuming both myFunc and someOtherFunction are defined in the module).
upvoted 2 times
...
october2
3 years, 2 months ago
A may be the right answer. ----- If the directive does not list specific functions to import or use * from to import all functions from a function module, you need to specify the module when you call the function from your script. ---- https://docs.mulesoft.com/mule-runtime/4.2/dw-functions
upvoted 2 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 ...