Skip to content
Sharp

Networking · interview question

When making an HTTP GET request using HttpClient, which method of HttpRequest is typically used?

Multiple choiceEasychapter-11-curatedpremiumnetworkinghttpclient-basics
java
HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://example.com")).build();
Choose one answer
Answer and explanation

Correct answer

B. Uri()

Why

The uri() method on HttpRequest.Builder is used to specify the target URI for the request. Although GET is the default method, specifying the URI is crucial for directing the request.

Test yourself on Networking

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

Start free test
All Networking questions →