Solved

Write a Code Fragment That Connects to a Server Running

Question 35

Multiple Choice

Write a code fragment that connects to a server running on gorge.divms.uiowa.edu at port 2345 and reads one line of text sent by the server.


A) Socket sock = new Socket(gorge.divms.uiowa.edu, 2345) ;
Scanner scan = new Scanner(sock.getOutputStream() ) ;
String line = scan.nextLine() ;
B) Socket sock = new Socket(gorge.divms.uiowa.edu, 2345) ;
Scanner scan = new Scanner(sock.getInputStream() ) ;
String line = scan.nextLine() ;
C) Scanner scan = new Scanner(sock.getInputStream() ) ;
Socket sock = new Socket(gorge.divms.uiowa.edu, 2345) ;
String line = scan.nextLine() ;
D) Socket sock = new Socket(2345, gorge.divms.uiowa.edu) ;
Scanner scan = new Scanner(sock.getInputStream() ) ;
String line = scan.next() ;

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents