exam questions

Exam 70-483 All Questions

View all questions & answers for the 70-483 exam

Exam 70-483 topic 1 question 82 discussion

Actual exam question from Microsoft's 70-483
Question #: 82
Topic #: 1
[All 70-483 Questions]

DRAG DROP -
You have a method named GetCustomerIDs that returns a list of integers. Each entry in the list represents a customer ID that is retrieved from a list named
Customers. The Customers list contains 1,000 rows.
Another developer creates a method named ValidateCustomer that accepts an integer parameter and returns a Boolean value. ValidateCustomer returns true if the integer provided references a valid customer. ValidateCustomer can take up to one second to run.
You need to create a method that returns a list of valid customer IDs. The code must execute in the shortest amount of time.
What should you do? (Develop the solution by selecting and ordering the required code snippets. You may not need all of the code snippets.)
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
Note:
* ParallelEnumerable.AsParallel Method
Enables parallelization of a query.
/ We parallelize the exution of the ValidateCustomer instances.

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
Xavios
Highly Voted 5 years, 7 months ago
1, 8, 7, 4 is the correct answer.
upvoted 36 times
FutureMfana
4 years, 10 months ago
Why do we need the .AsParallel?
upvoted 2 times
Garylim
4 years, 4 months ago
Refer here: https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/introduction-to-plinq
upvoted 2 times
...
...
thiemamd
4 years, 4 months ago
I agree with you
upvoted 2 times
...
...
auderis
Most Recent 3 years, 10 months ago
And the solution is without AsParallel()... Check here: https://dotnetfiddle.net/GGtemK
upvoted 1 times
...
DaGrooveNL
3 years, 10 months ago
FINAL ANSWER: 1.public List<Int32> GetValidCustomers() 1.{ 8. List<Int32> validCustomers = 7. (from c in customers.AsParallel() 7. where ValidateCustomer(c) 7. select c).ToList(); 4. return validCustomers; 4.}
upvoted 3 times
M62
3 years, 10 months ago
I agree with DaGrooveNL
upvoted 1 times
...
...
HgstExam
4 years, 3 months ago
For me the solution is : 1.public List<Int32> GetValidCustomers() 1.{ 8. List<Int32> validCustomers = 5. (from c in customers 5. where ValidateCustomer(c) 5. select c).AsParallel().ToList(); 4. return validCustomers; 4.}
upvoted 3 times
HgstExam
4 years, 3 months ago
To me you need ValidateCustomer(c) in your parallelism (which takes time), so therefore 7 would be slower than 5
upvoted 1 times
lomanov
4 years, 3 months ago
https://stackoverflow.com/questions/40205384/where-to-call-asparallel-in-a-linq-query
upvoted 1 times
...
...
HgstExam
4 years, 3 months ago
Ok After some tests I take back my anwser. It seems that the enumerable will still execute synchronously and only the results will be done AsParallel() which is not what I expected, so it should be: 1.public List<Int32> GetValidCustomers() 1.{ 8. List<Int32> validCustomers = 7. (from c in customers.AsParallel() 7. where ValidateCustomer(c) 7. select c).ToList(); 4. return validCustomers; 4.}
upvoted 8 times
dutchHunter
4 years, 2 months ago
So: 1, 8, 5, 4
upvoted 1 times
noussa
3 years, 11 months ago
No it's 1 8 7 4 cause AsParallel() needs to be from source not at the end. something like this: var evenNums = from num in numbers.AsParallel().AsOrdered() where num % 2 == 0 select num;
upvoted 3 times
...
...
...
...
justpassingexam
4 years, 4 months ago
It's obvious - 1,8,7,4.
upvoted 4 times
...
thiemamd
4 years, 4 months ago
I agree with 5, 8
upvoted 1 times
thiemamd
4 years, 4 months ago
oh nop. I agree with @Xavios
upvoted 2 times
...
...
TonyBezerra
4 years, 10 months ago
I think the correct answers are 1, 2, 7 and 4.
upvoted 2 times
tanujgyan
4 years, 8 months ago
You cannot return a task, your return type is list so 2 will not fit the answer
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 ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago