Lecture 3 Flashcards

1
Q

What is client-server communication?

A

Client-server communication refers to the exchange of data between two entities: a client and a server. The client initiates requests, and the server processes these requests and returns responses.

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

Why is structuring messages in client-server communication important?

A

Structuring messages ensures that the server has the necessary information to handle and respond to the client’s requests appropriately.

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

What is the purpose of the String Tokenizer class in Java?

A

The String Tokenizer class, within the java.util package, breaks down strings into smaller units called tokens based on specified delimiters.

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

How does String Tokenizer operate?

A

String Tokenizer scans through the input string, identifies occurrences of specified delimiters, marks the end of a token, and continues this process until the entire string is tokenized.

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

What is the advantage of using String Tokenizer for client-server communication in a chat application?

A

String Tokenizer allows efficient parsing of incoming messages, enabling the extraction of relevant information such as the sender, recipient, and message content.

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

Name the three constructors of the StringTokenizer class.

A

StringTokenizer(String str)
StringTokenizer(String str, String delim)
StringTokenizer(String str, String delim, boolean returnValue)

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

What does the StringTokenizer(String str) constructor do?

A

It creates a StringTokenizer with the specified string.

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

What does the StringTokenizer(String str, String delim, boolean returnValue) constructor do?

A

t creates a StringTokenizer with the specified string, delimiter, and returnValue. If returnValue is true, delimiter characters are considered tokens; if false, they serve to separate tokens.

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

What does the StringTokenizer(String str, String delim) constructor do?

A

t creates a StringTokenizer with the specified string and delimiter.

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

What does the hasMoreTokens() method do?

A

it checks if there are more tokens available.

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

List some methods of the StringTokenizer class.

A

boolean hasMoreTokens()
String nextToken()
String nextToken(String delim)
boolean hasMoreElements()
Object nextElement()
int countTokens()

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

What does the nextToken() method do?

A

It returns the next token from the StringTokenizer object.

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

What does the nextToken(String delim) method do?

A

It returns the next token based on the specified delimiter.

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

What does the countTokens() method do?

A

It returns the total number of tokens

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

Why is string tokenization beneficial in client-server communication?

A

it ensures uniform message formatting, simplifies parsing, provides flexibility with custom delimiters, offers efficiency, and promotes code maintainability.

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

What components might a message from a client to a server contain in a chat application?

A

A message may contain components such as command, sender ID, recipient ID, and message content.

17
Q

How does String Tokenizer promote efficiency in client-server communication?

A

By offering optimized performance for parsing complex or large messages, enhancing the responsiveness and scalability of the communication.

18
Q

Why string tokenizer

A

It is standard: ensures uniform formatting
Simplified parsing
Flexible: can define custom delimeters and tokenization rules
Efficient
It is maintainable