wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JAVA QUIZ

Total questions: 15

Worksheet time: 9mins

Name
Class
Date
1.

Which protocol is reliable and connection-oriented in network programming?

a)

A) UDP

b)

B) HTTP

c)

C) TCP

d)

D) IP

2.

Which Java class is used to represent IP addresses?

a)

A) Socket

b)

B) ServerSocket

c)

C) URLConnection

d)

D) InetAddress

3.

Which package in Java provides classes and interfaces for network programming?

b)
c)

C) java.util

d)

D) java.lang

4.

Which method is used to establish a connection in the Socket class?

a)

A) openConnection()

b)

B) accept()

c)

C) connect()

d)

D) getInputStream()

5.

Which protocol is lightweight and connectionless in network programming?

a)

A) TCP

b)

B) FTP

c)

C) UDP

d)

D) SMTP

6.

Which class is used to create a TCP server in Java?

a)

A) ServerSocket

b)

B) Socket

c)

C) DatagramSocket

d)

D) URLConnection

7.

Which method is used to send data over a TCP socket?

a)

A) send()

b)

B) write()

c)

C) transmit()

d)

D) OutputStream()

8.

Which class is used to create a UDP server in Java?

a)

A) DatagramSocket

b)

B) ServerSocket

c)

C) Socket

d)

D) URLConnection

9.

Which Java class is used for handling HTTP connections and requests?

a)

A) URLConnection

b)

B) Socket

c)

C) HttpURLConnection

d)

D) ServerSocket

10.

Which package in Java provides support for asynchronous networking?

a)

A) java.nio

b)

B) java.util.concurrent

c)

C) java.lang

11.

Which class is used for non-blocking I/O operations in Java NIO?

a)

A) Socket

b)

B) DatagramSocket

c)

C) Selector

d)

D) ServerSocket

12.

Which method is used to read data from a TCP socket?

a)

A) send()

b)

B) write()

c)

C) receive()

d)

D) InputStream()

13.

Which Java library is commonly used for network communication in a client-server architecture?

a)

A) Apache HttpClient

b)

B) Netty

c)

C) Spring Web

d)

D) All of the above

14.

Which method is used to establish a connection in the HttpURLConnection class?

a)

A) openConnection()

b)

B) accept()

c)

C) connect()

d)

D) getInputStream()

15.

Which class is used to handle datagram-based communication in Java?

a)

A) DatagramSocket

b)

B) ServerSocket

c)

C) Socket

d)

D) URLConnection