exam questions

Exam Professional Cloud Developer All Questions

View all questions & answers for the Professional Cloud Developer exam

Exam Professional Cloud Developer topic 1 question 75 discussion

Actual exam question from Google's Professional Cloud Developer
Question #: 75
Topic #: 1
[All Professional Cloud Developer Questions]

Your teammate has asked you to review the code below, which is adding a credit to an account balance in Cloud Datastore.
Which improvement should you suggest your teammate make?

  • A. Get the entity with an ancestor query.
  • B. Get and put the entity in a transaction.
  • C. Use a strongly consistent transactional database.
  • D. Don't return the account entity from the function.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

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
santoshchauhan
7 months, 3 weeks ago
Selected Answer: B
B. Get and put the entity in a transaction. The code provided is updating an account balance in Cloud Datastore. To ensure data integrity and consistency, such an update should be done within a transaction to avoid issues with concurrent updates which could result in an incorrect balance if the account is accessed by multiple processes at the same time.
upvoted 1 times
...
__rajan__
1 year, 1 month ago
Selected Answer: B
Put the entity in transaction
upvoted 1 times
...
omermahgoub
1 year, 9 months ago
B. Get and put the entity in a transaction. It is a good practice to perform a get and put within a transaction to ensure that the update to the balance is atomic. This prevents other processes from reading the balance and making updates to it simultaneously, which could lead to incorrect or inconsistent results. By using a transaction, your teammate can ensure that the balance is updated correctly and consistently.
upvoted 3 times
...
tomato123
2 years, 2 months ago
Selected Answer: B
B is correct
upvoted 3 times
...
ParagSanyashiv
2 years, 9 months ago
Selected Answer: B
B is correct option in this case
upvoted 1 times
...
syu31svc
3 years, 3 months ago
https://cloud.google.com/datastore/docs/concepts/transactions#uses_for_transactions: "This requires a transaction because the value of balance in an entity may be updated by another user after this code fetches the object, but before it saves the modified object. Without a transaction, the user's request uses the value of balance prior to the other user's update, and the save overwrites the new value. With a transaction, the application is told about the other user's update." B is the answer
upvoted 4 times
...
[Removed]
3 years, 9 months ago
The answer is B.
upvoted 1 times
StelSen
3 years, 8 months ago
Yes Option-B is correct. Here is the link: https://cloud.google.com/datastore/docs/concepts/transactions#using_transactions
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