Skip to content
Sharp

Networking · interview question

Which method of HttpClient is used to set a timeout for requests?

Multiple choiceMediumchapter-11-curatedpremiumnetworkingjson-serialization
Choose one answer
Answer and explanation

Correct answer

C. HttpClient.Builder.connectTimeout()

Why

The HttpClient.Builder.connectTimeout() method is used to set a timeout for HTTP requests, ensuring that connections don't hang indefinitely if a server fails to respond.

Test yourself on Networking

A free test with instant, explained results. No account needed.

Start free test
All Networking questions →