Skip to content
Sharp

Networking · interview question

Which method would you use to set a custom timeout for an HttpClient in Java?

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

Correct answer

D. HttpClient.Builder.connectTimeout

Why

The HttpClient.Builder.connectTimeout method is used to specify the maximum time to wait for establishing a connection. Setting appropriate timeouts helps in avoiding indefinite waits and handling network latency more effectively.

Test yourself on Networking

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

Start free test
All Networking questions →