Free GCP-PCD Sample Questions — Google Cloud Platform - Professional Cloud Developer

Free GCP-PCD sample questions for the Google Cloud Platform - Professional Cloud Developer exam. No account required: study at your own pace.

Want an interactive quiz? Take the full GCP-PCD practice test

Looking for more? Click here to get the full PDF with 307+ practice questions for $10 for offline study and deeper preparation.

Question 1

You are building an application that will store frequently accessed data in a Memorystore for Redis Cluster instance. You would like to make the application resilient to network issues. You need to ensure that the application handles client disconnections from a Redis instance gracefully to minimize disruption and ensure stability of the application. What should you do?

  • A. Immediately terminate the application instance upon detecting a Redis disconnection to force a restart, and wait for clients to reconnect to the cache as soon as the application becomes available
  • B. Configure the Redis client to reconnect after a fixed delay of 60 seconds
  • C. Use Memorystore’s automatic failover mechanisms to make the Redis cache available in a secondary zone
  • D. Implement exponential backoff with a jitter when reconnecting after a disconnection. Configure client-side caching to serve data during brief outages
Show Answer
Correct Answer:
D. Implement exponential backoff with a jitter when reconnecting after a disconnection. Configure client-side caching to serve data during brief outages
Question 2

You plan to deploy a new Go application to Cloud Run. The source code is stored in Cloud Source Repositories. You need to configure a fully managed, automated, continuous deployment pipeline that runs when a source code commit is made. You want to use the simplest deployment solution. What should you do?

  • A. Configure a cron job on your workstations to periodically run gcloud run deploy --source in the working directory
  • B. Configure a Jenkins trigger to run the container build and deploy process for each source code commit to Cloud Source Repositories
  • C. Configure continuous deployment of new revisions from a source repository for Cloud Run using buildpacks
  • D. Use Cloud Build with a trigger configured to run the container build and deploy process for each source code commit to Cloud Source Repositories
Show Answer
Correct Answer:
D. Use Cloud Build with a trigger configured to run the container build and deploy process for each source code commit to Cloud Source Repositories
Question 3

You are developing an event-driven application. You have created a topic to receive messages sent to Pub/Sub. You want those messages to be processed in real time. You need the application to be independent from any other system and only incur costs when new messages arrive. How should you configure the architecture?

  • A. Deploy the application on Compute Engine. Use a Pub/Sub push subscription to process new messages in the topic
  • B. Deploy your code on Cloud Functions. Use a Pub/Sub trigger to invoke the Cloud Function. Use the Pub/Sub API to create a pull subscription to the Pub/Sub topic and read messages from it
  • C. Deploy the application on Google Kubernetes Engine. Use the Pub/Sub API to create a pull subscription to the Pub/Sub topic and read messages from it
  • D. Deploy your code on Cloud Functions. Use a Pub/Sub trigger to handle new messages in the topic
Show Answer
Correct Answer:
D. Deploy your code on Cloud Functions. Use a Pub/Sub trigger to handle new messages in the topic
Question 4

Your team developed a web-based game that has many simultaneous players. Recently, users have started to complain that the leaderboard tallies the top scores too slowly. You investigated the issue and discovered that the application stack is currently using Cloud SQL for PostgreSQL. You want to improve the leaderboard performance as much as possible to provide a better user experience. What should you do?

  • A. Re-implement the leaderboard data to be stored in Memorystore for Redis
  • B. Optimize the SQL queries to minimize slow-running queries
  • C. Migrate the database and store the data in AlloyDB
  • D. Update Cloud SQL for PostgreSQL to the latest version
Show Answer
Correct Answer:
A. Re-implement the leaderboard data to be stored in Memorystore for Redis
Question 5

Your company has created an application that uploads a report to a Cloud Storage bucket. When the report is uploaded to the bucket, you want to publish a message to a Cloud Pub/Sub topic. You want to implement a solution that will take a small amount to effort to implement. What should you do?

  • A. Configure the Cloud Storage bucket to trigger Cloud Pub/Sub notifications when objects are modified
  • B. Create an App Engine application to receive the file; when it is received, publish a message to the Cloud Pub/Sub topic
  • C. Create a Cloud Function that is triggered by the Cloud Storage bucket. In the Cloud Function, publish a message to the Cloud Pub/Sub topic
  • D. Create an application deployed in a Google Kubernetes Engine cluster to receive the file; when it is received, publish a message to the Cloud Pub/Sub topic
Show Answer
Correct Answer:
A. Configure the Cloud Storage bucket to trigger Cloud Pub/Sub notifications when objects are modified
Question 6

You have a container deployed on Google Kubernetes Engine. The container can sometimes be slow to launch, so you have implemented a liveness probe. You notice that the liveness probe occasionally fails on launch. What should you do?

  • A. Add a startup probe
  • B. Increase the initial delay for the liveness probe
  • C. Increase the CPU limit for the container
  • D. Add a readiness probe
Show Answer
Correct Answer:
A. Add a startup probe
Question 7

You plan to deploy a new application revision with a Deployment resource to Google Kubernetes Engine (GKE) in production. The container might not work correctly. You want to minimize risk in case there are issues after deploying the revision. You want to follow Google-recommended best practices. What should you do?

  • A. Perform a rolling update with a PodDisruptionBudget of 80%
  • B. Perform a rolling update with a HorizontalPodAutoscaler scale-down policy value of 0
  • C. Convert the Deployment to a StatefulSet, and perform a rolling update with a PodDisruptionBudget of 80%
  • D. Convert the Deployment to a StatefulSet, and perform a rolling update with a HorizontalPodAutoscaler scale-down policy value of 0
Show Answer
Correct Answer:
A. Perform a rolling update with a PodDisruptionBudget of 80%
Question 8

You are developing an application component to capture user behavior data and stream the data to BigQuery. You plan to use the BigQuery Storage Write API. You need to ensure that the data that arrives in BigQuery does not have any duplicates. You want to use the simplest operational method to achieve this. What should you do?

  • A. Create a write stream in the default type
  • B. Create a write stream in the committed type
  • C. Configure a Kafka cluster. Use a primary universally unique identifier (UUID) for duplicate messages
  • D. Configure a Pub/Sub topic. Use Cloud Functions to subscribe to the topic and remove any duplicates
Show Answer
Correct Answer:
B. Create a write stream in the committed type
Question 9

You are designing a resource-sharing policy for applications used by different teams in a Google Kubernetes Engine cluster. You need to ensure that all applications can access the resources needed to run. What should you do? (Choose two.)

  • A. Specify the resource limits and requests in the object specifications
  • B. Create a namespace for each team, and attach resource quotas to each namespace
  • C. Create a LimitRange to specify the default compute resource requirements for each namespace
  • D. Create a Kubernetes service account (KSA) for each application, and assign each KSA to the namespace
  • E. Use the Anthos Policy Controller to enforce label annotations on all namespaces. Use taints and tolerations to allow resource sharing for namespaces
Show Answer
Correct Answer:
  • B. Create a namespace for each team, and attach resource quotas to each namespace
  • C. Create a LimitRange to specify the default compute resource requirements for each namespace
Question 10

You are developing an application that will store and access sensitive unstructured data objects in a Cloud Storage bucket. To comply with regulatory requirements, you need to ensure that all data objects are available for at least 7 years after their initial creation. Objects created more than 3 years ago are accessed very infrequently (less than once a year). You need to configure object storage while ensuring that storage cost is optimized. What should you do? (Choose two.)

  • A. Set a retention policy on the bucket with a period of 7 years
  • B. Use IAM Conditions to provide access to objects 7 years after the object creation date
  • C. Enable Object Versioning to prevent objects from being accidentally deleted for 7 years after object creation
  • D. Create an object lifecycle policy on the bucket that moves objects from Standard Storage to Archive Storage after 3 years
  • E. Implement a Cloud Function that checks the age of each object in the bucket and moves the objects older than 3 years to a second bucket with the Archive Storage class. Use Cloud Scheduler to trigger the Cloud Function on a daily schedule
Show Answer
Correct Answer:
  • A. Set a retention policy on the bucket with a period of 7 years
  • D. Create an object lifecycle policy on the bucket that moves objects from Standard Storage to Archive Storage after 3 years
Question 11

You are tasked with using C++ to build and deploy a microservice for an application hosted on Google Cloud. The code needs to be containerized and use several custom software libraries that your team has built. You want to minimize maintenance of the application’s underlying infrastructure. How should you deploy the microservice?

  • A. Use Cloud Run functions to deploy the microservice
  • B. Use Cloud Build to create the container, and deploy it on Cloud Run
  • C. Use Cloud Shell to containerize your microservice, and deploy it on GKE Standard
  • D. Use Cloud Shell to containerize your microservice, and deploy it on a Container-Optimized OS Compute Engine instance
Show Answer
Correct Answer:
B. Use Cloud Build to create the container, and deploy it on Cloud Run
Question 12

You are running an application on App Engine that you inherited. You want to find out whether the application is using insecure binaries or is vulnerable to XSS attacks. Which service should you use?

  • A. Cloud Amor
  • B. Stackdriver Debugger
  • C. Cloud Security Scanner
  • D. Stackdriver Error Reporting
Show Answer
Correct Answer:
C. Cloud Security Scanner
Question 13

You are designing an application that will subscribe to and receive messages from a single Pub/Sub topic and insert corresponding rows into a database. Your application runs on Linux and leverages preemptible virtual machines to reduce costs. You need to create a shutdown script that will initiate a graceful shutdown. What should you do?

  • A. Write a shutdown script that uses inter-process signals to notify the application process to disconnect from the database
  • B. Write a shutdown script that broadcasts a message to all signed-in users that the Compute Engine instance is going down and instructs them to save current work and sign out
  • C. Write a shutdown script that writes a file in a location that is being polled by the application once every five minutes. After the file is read, the application disconnects from the database
  • D. Write a shutdown script that publishes a message to the Pub/Sub topic announcing that a shutdown is in progress. After the application reads the message, it disconnects from the database
Show Answer
Correct Answer:
A. Write a shutdown script that uses inter-process signals to notify the application process to disconnect from the database
Question 14

Your company uses Cloud Logging to manage large volumes of log data. You need to build a real-time log analysis architecture that pushes logs to a third-party application for processing. What should you do?

  • A. Create a Cloud Logging log export to Pub/Sub
  • B. Create a Cloud Logging log export to BigQuery
  • C. Create a Cloud Logging log export to Cloud Storage
  • D. Create a Cloud Function to read Cloud Logging log entries and send them to the third-party application
Show Answer
Correct Answer:
A. Create a Cloud Logging log export to Pub/Sub
Question 15

You are writing a Compute Engine hosted application in project A that needs to securely authenticate to a Cloud Pub/Sub topic in project B. What should you do?

  • A. Configure the instances with a service account owned by project B. Add the service account as a Cloud Pub/Sub publisher to project A
  • B. Configure the instances with a service account owned by project A. Add the service account as a publisher on the topic
  • C. Configure Application Default Credentials to use the private key of a service account owned by project B. Add the service account as a Cloud Pub/Sub publisher to project A
  • D. Configure Application Default Credentials to use the private key of a service account owned by project A. Add the service account as a publisher on the topic
Show Answer
Correct Answer:
B. Configure the instances with a service account owned by project A. Add the service account as a publisher on the topic
Question 16

Users are complaining that your Cloud Run-hosted website responds too slowly during traffic spikes. You want to provide a better user experience during traffic peaks. What should you do?

  • A. Read application configuration and static data from the database on application startup
  • B. Package application configuration and static data into the application image during build time
  • C. Perform as much work as possible in the background after the response has been returned to the user
  • D. Ensure that timeout exceptions and errors cause the Cloud Run instance to exit quickly so a replacement instance can be started
Show Answer
Correct Answer:
B. Package application configuration and static data into the application image during build time
Question 17

You are planning to add unit tests to your application. You need to be able to assert that published Pub/Sub messages are processed by your subscriber in order. You want the unit tests to be cost-effective and reliable. What should you do?

  • A. Implement a mocking framework
  • B. Create a topic and subscription for each tester
  • C. Add a filter by tester to the subscription
  • D. Use the Pub/Sub emulator
Show Answer
Correct Answer:
D. Use the Pub/Sub emulator
Question 18

Your company stores their source code in a Cloud Source Repositories repository. Your company wants to build and test their code on each source code commit to the repository and requires a solution that is managed and has minimal operations overhead. Which method should they use?

  • A. Use Cloud Build with a trigger configured for each source code commit
  • B. Use Jenkins deployed via the Google Cloud Platform Marketplace, configured to watch for source code commits
  • C. Use a Compute Engine virtual machine instance with an open source continuous integration tool, configured to watch for source code commits
  • D. Use a source code commit trigger to push a message to a Cloud Pub/Sub topic that triggers an App Engine service to build the source code
Show Answer
Correct Answer:
A. Use Cloud Build with a trigger configured for each source code commit
Question 19

You are developing an application that will allow clients to download a file from your website for a specific period of time. How should you design the application to complete this task while following Google-recommended best practices?

  • A. Configure the application to send the file to the client as an email attachment
  • B. Generate and assign a Cloud Storage-signed URL for the file. Make the URL available for the client to download
  • C. Create a temporary Cloud Storage bucket with time expiration specified, and give download permissions to the bucket. Copy the file, and send it to the client
  • D. Generate the HTTP cookies with time expiration specified. If the time is valid, copy the file from the Cloud Storage bucket, and make the file available for the client to download
Show Answer
Correct Answer:
B. Generate and assign a Cloud Storage-signed URL for the file. Make the URL available for the client to download
Question 20

You noticed that your application was forcefully shut down during a Deployment update in Google Kubernetes Engine. Your application didn’t close the database connection before it was terminated. You want to update your application to make sure that it completes a graceful shutdown. What should you do?

  • A. Update your code to process a received SIGTERM signal to gracefully disconnect from the database
  • B. Configure a PodDisruptionBudget to prevent the Pod from being forcefully shut down
  • C. Increase the terminationGracePeriodSeconds for your application
  • D. Configure a PreStop hook to shut down your application
Show Answer
Correct Answer:
A. Update your code to process a received SIGTERM signal to gracefully disconnect from the database

Aced these? Get the Full Exam

Download the complete GCP-PCD study bundle with 307+ questions in a single printable PDF.