Multiple choice

Which of the following statements is/are valid to create a server socket?

  1. ServerSocket s1 = new ServerSocket(25);

  2. ServerSocket s1 = new ServerSocket(8000);

  3. ServerSocket s1 = new ServerSocket(80);

  4. Both (1) and (3)

  5. ServerSocket s1 = new ServerSocket(21);

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

To establish a server, you need to create a server socket and attach it to a port, which is where server listens for the connections. The port numbers are ranged from 0 to 65536, but port numbers 0 to 1024 are reserved for privileged services.The syntax to create a server socket is: ServerSocket objectname = new ServerSocket(port);