Home » JAVA Programming » Networking » Question
  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. garbage value
    2. 1
    3. -1
    4. 0
    5. None of these
Correct Option: C

Since we have not explicitly set the port default value that is -1 is printed.



Your comments will be displayed only after manual approval.