HeadFirst Java says that the ip address that I have put in double quotes can be replaced by the domain name.Could somebody tell me how that would work.With a real life example. Please don't redirect me to some site with tons of api descriptions. Just give me a nice example, like the examples in HFJ. Can I connect to the Google server and send a search query as a String to it using printWriter object
Yes, you can, but not on port 5000, and not quite as easily as you seem to assume. HTTP generally uses port 80 (or port 443 for HTTPS), and you would need to send and receive HTTP over the socket. So it's not like a web browser where you can simply enter the URL and get back a web page.
But you don't have to implement all that - the java.net package has classes that do all this for you, like URL, URLConnection and HttpURLConnection.