Networking
- What is the output of this program?
import java.net.*;
public class Networking_Port
{
public static void main(String[] args) throws MalformedURLException
{
URL object = new URL("https://www.interviewmania.com/programming");
System.out.print(object.getPort());
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Since we have not explicitly set the port default value that is -1 is printed.
- What is the output of this program?
import java.net.*;
public class Networking_Host
{
public static void main(String[] args) throws MalformedURLException
{
URL object = new URL("https://www.interviewmania.com/programming");
System.out.print(object.getHost());
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
www.interviewmania.com
- What is the output of this program?
import java.net.*;
public class Networking_Example
{
public static void main(String[] args) throws MalformedURLException
{
URL object = new URL("https://www.interviewmania.com/programming");
System.out.print(object.toExternalForm());
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
toExternalForm() is used to know the full URL of an URL object.
- Which of these is a wrapper around everything associated with a reply from an http server?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
HttpResponse is wrapper around everything associated with a reply from an http server.
- Which of these transfer protocol must be used so that URL can be accessed by URLConnection class object?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
For a URL to be accessed from remote location http protocol must be used.