Bird
0
0

Given this pseudocode snippet, what will happen if the service call takes 7 seconds?

medium📝 Analysis Q4 of 15
Microservices - Resilience Patterns
Given this pseudocode snippet, what will happen if the service call takes 7 seconds?
try {
  response = callService(timeout=5000)
  print('Success')
} catch TimeoutException {
  print('Timeout occurred')
}
APrints 'Timeout occurred'
BPrints 'Success'
CThrows an unhandled exception
DRetries the call automatically
Step-by-Step Solution
Solution:
  1. Step 1: Understand timeout setting

    The timeout is set to 5000 ms (5 seconds), but the call takes 7 seconds.
  2. Step 2: Effect of timeout exceeded

    Since call exceeds timeout, a TimeoutException is thrown and caught, printing 'Timeout occurred'.
  3. Final Answer:

    Prints 'Timeout occurred' -> Option A
  4. Quick Check:

    Timeout exceeded triggers exception catch [OK]
Quick Trick: Timeout triggers exception if exceeded [OK]
Common Mistakes:
MISTAKES
  • Assuming success despite timeout
  • Expecting automatic retry
  • Missing exception handling

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes