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
Q24: What does the acronym SMTP stand for?
A)Simple
Q28: A(n) _ describes how data for a
Q30: Which code fragment creates a server running
Q30: Which of the following HTTP commands supplies
Q31: Show the command line that establishes a
Q32: a(n. _ is a pointer to an
Q33: The _ is used to download received
Q34: A _ is an object that encapsulates
Q35: Write a code fragment that connects to
Q36: Which of the following is not an
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents