Multiple Choice
Suppose that sock refers to a TCP socket connected to another machine, and in is aScanner. Which code sends the string "Who is there?" to the other machine, receives the return answer, and then prints it?
A) PrintWriter pw = new PrintWriter(sock.getOutputStream() .println("Who is there?") ) ;
InputStream instream = sock.getInputStream() ;
Scanner in = new Scanner(instream) ;
System.out.println(in.nextLine() ) ;
B) PrintWriter pw = new PrintWriter(sock.getInputStream() ) ;
pw.println("Who is there?") ;
pw.flush() ;
InputStream instream = sock.getInputStream() ;
Scanner in = new Scanner(instream) ;
System.out.println(in.nextLine() ) ;
C) PrintWriter pw = new PrintWriter(sock.getOutputStream() ) ;
pw.flush("Who is there") ;
InputStream instream = sock.getInputStream() ;
Scanner in = new Scanner(instream) ;
System.out.println(in.nextLine() ) ;
D) PrintWriter pw = new PrintWriter(sock.getOutputStream() ) ;
pw.println("Who is there?") ;
pw.flush() ;
InputStream instream = sock.getInputStream() ;
Scanner in = new Scanner(instream) ;
System.out.println(in.nextLine() ) ;
Correct Answer:

Verified
Correct Answer:
Verified
Q1: What does the following if statement do?<br>If
Q3: Each IP _ is delivered separately, and
Q8: Show the command line that establishes a
Q9: Which of the following HTTP commands supplies
Q12: Which of the following protocols is used
Q38: To connect to the HTTP port (80)
Q40: Which of the following is not an
Q47: The HTTP command GET _.<br>A)returns the requested
Q52: _ attempts reliable delivery of data, with
Q57: Which of the following statements is correct?<br>A)HTML