Networking


  1. Which of these is a wrapper around everything associated with a reply from an http server?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    HttpResponse is wrapper around everything associated with a reply from an http server.


  1. 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());
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    www.interviewmania.com



  1. 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());
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    toExternalForm() is used to know the full URL of an URL object.


  1. 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());
    }
    }












  1. 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.



  1. Which of these transfer protocol must be used so that URL can be accessed by URLConnection class object?











  1. 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.