Discord Flashcards

1
Q

InputStreamReader

A
  • Bridge from byte streams to char streams
  • Reads bytes and decodes them into characters using the specified charset
  • Should always be wrapped in a BufferedReader
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what does the server socket do?

A

listens for connections on the specified port
new ServerSocket(port);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

how does a ServerSocket accept a connection from a client Socket?

A

Socket clientSocket = serverSocket.accept()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

PrintWriter

A

wraps an output stream
new PrintWriter(outputStream)
automatic line flushing
can’t write raw bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What 5 things do you need to implement a ChatServer?

A
  • ServerSocket
  • Socket clientSocket
  • BufferedReader in
  • PrintWriter out
  • Scanner to read from keyboard
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Runnable

A

A class that implements Runnable can run without subclassing Thread by instantiating a Thread instance and passing itself in as the target.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what does scanner take as a param?

A

System.in

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

checklist

A

start threads
close sockets
update loop variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

difference between streams and readers

A

stream work with binary data and readers work with characters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

DataInputStream

A

read primitive java data types in machine-independent way

How well did you know this?
1
Not at all
2
3
4
5
Perfectly