Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

fill in these blanks to make the server start to run on a localhost import java.

ID: 3664539 • Letter: F

Question

fill in these blanks to make the server start to run on a localhost

import java.__________.*;

import java.io.*;

public class NewServer

{

    //Create a socket for the server to be setup on.

    private static __________ server;

   

    //Establish a Port Number for the server.

    final static int PORT = 9999;

   

    //Main Execution

    public static void main(String[] args)

    {

        //Catch any exceptions raised in transmission.

        try

        {

            //Create the server’s access point.

            server = new __________(__________);

            //Print a confirmation message to the console.

            System.out.println(“Server started.”);

        }

        //Catch a possible exception.

        catch (__________ ex)

        {

            //Tell the server what threw the exception.

            ex.printStackTrace();

        }

    }

}

Explanation / Answer

import java.io.*;
import java.net.*;

public class NewServer

{


//Create a socket for the server to be setup on.
    private static ServerSocket server;

    //Establish a Port Number for the server.

    final static int PORT = 9999;

    //Main Execution

    public static void main(String[] args)

    {

        //Catch any exceptions raised in transmission.

        try

        {

            //Create the server’s access point.

            server = new ServerSocket(PORT);

            //Print a confirmation message to the console.

            System.out.println("Server started");

        }

        //Catch a possible exception.

        catch (IOException ex)

        {

            //Tell the server what threw the exception.

            ex.printStackTrace();

        }

    }

}