wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Networking Fundamentals

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is a socket in Java?

a)

A socket in Java is a type of data structure.

b)

A socket in Java is an endpoint for communication between two machines.

c)

A socket in Java is used for storing files.

d)

A socket in Java is a graphical user interface component.

2.

Explain the difference between TCP and UDP.

a)

TCP is reliable and connection-oriented, while UDP is faster and connectionless.

b)

TCP is connectionless and has lower latency than UDP.

c)

UDP guarantees delivery of packets, while TCP does not.

d)

TCP is faster and connection-oriented, while UDP is reliable and connectionless.

3.

What are the main layers of the TCP/IP model?

a)

Network, Internet, Link, Session

b)

Application, Network, Transport, Physical

c)

Application, Transport, Internet, Network Interface

d)

Session, Transport, Internet, Data Link

4.

How does a client-server architecture work?

a)

Clients store all data locally without any server interaction.

b)

Clients directly communicate with each other without a server.

c)

The server sends requests to multiple clients simultaneously.

d)

A client-server architecture works by having clients send requests to a server, which processes the requests and returns responses.

5.

What is the purpose of the transport layer in the TCP/IP model?

a)

To establish physical connections between devices.

b)

To manage network routing and addressing.

c)

To provide reliable data transfer and communication between applications.

d)

To encrypt data for secure transmission.

6.

Describe how to create a simple TCP server in Java.

a)

Use DatagramSocket for UDP communication

b)

Create a TCP server using ServerSocket, accept connections in a loop, and handle client communication with InputStream and OutputStream.

c)

Implement a web server using HttpServer

d)

Create a GUI application for client-server interaction

7.

What is the role of the IP protocol in networking?

a)

The IP protocol manages user authentication in networks.

b)

The IP protocol encrypts data for secure transmission.

c)

The IP protocol is responsible for physical data transmission over cables.

d)

The IP protocol facilitates addressing and routing of data packets in networking.

8.

How do you handle multiple clients in a Java socket server?

a)

Use a blocking I/O approach for all client connections.

b)

Use multithreading to spawn a new thread for each client connection.

c)

Use a single-threaded model to handle all clients sequentially.

d)

Limit the server to only one client at a time.

9.

What are the advantages of using UDP over TCP?

a)

Higher reliability due to error correction

b)

Guaranteed delivery of packets

c)

More efficient for file transfers

d)

Lower latency

10.

Explain the concept of port numbers in networking.

a)

Port numbers are used to identify specific processes or services on a networked device.

b)

Port numbers are only relevant for wireless networks.

c)

Port numbers are used to encrypt data during transmission.

d)

Port numbers are physical connectors on a network device.

11.

What is a DatagramSocket in Java?

a)

A DatagramSocket is a graphical user interface component in Java.

b)

A DatagramSocket is a Java class for managing TCP connections.

c)

A DatagramSocket is a Java class used for sending and receiving datagram packets over a network using UDP.

d)

A DatagramSocket is used for sending and receiving files over HTTP.

12.

How does the three-way handshake work in TCP?

a)

Through a SYN, SYN-ACK, and ACK sequence.

b)

The three-way handshake involves only a single SYN message.

c)

The three-way handshake uses a SYN, FIN, and RST sequence.

d)

The three-way handshake is a method for data encryption.

13.

What is the significance of the application layer in the TCP/IP model?

a)

The application layer enables user-level applications to communicate over the network using defined protocols.

b)

The application layer encrypts data for secure transmission.

c)

The application layer is responsible for routing packets across networks.

d)

The application layer manages hardware resources directly.

14.

How can you implement a simple UDP client in Java?

a)

Use a Socket instead of DatagramSocket.

b)

Send data as a String instead of a byte array.

c)

Establish a TCP connection before sending data.

d)

1. Create a DatagramSocket. 2. Prepare data as a byte array. 3. Create a DatagramPacket with the data, server address, and port. 4. Send the packet using the socket. 5. Optionally, receive a response using another DatagramPacket.

15.

What are some common network protocols used in the application layer?

a)

TCP, UDP, IP

b)

HTTP, FTP, SMTP, DNS

c)

SSH, Telnet, SNMP

d)

RDP, ICMP, ARP