You are on page 1of 5

Java 2m

1) Parsing URL

"https://www.google.com/search?
q=javatpoint&oq=javatpoint&sourceid=chrome&ie=UTF-8"

2) Difference between final, finally and finalize

Java 2m 1
3) Difference between Multi-tasking and Multi-
threading
Multi-tasking
Multi-tasking is the ability of an operating system to run multiple processes or
tasks concurrently, sharing the same processor and other resources.

In multi-tasking, the operating system divides the CPU time between multiple
tasks, allowing them to execute simultaneously.

Each task is assigned a time slice, or a portion of CPU time, during which it can
execute its code.

Multi-tasking is essential for increasing system efficiency, improving user


productivity, and achieving optimal resource utilization.

Multi-threading
Multi-threading is a technique in which an operating system divides a single
process into multiple threads, each of which can execute concurrently.

Threads share the same memory space and resources of the parent process,
allowing them to communicate and synchronize data easily.

Multi-threading is useful for improving application performance by allowing


different parts of the application to execute simultaneously.

4) Window Listener

Java 2m 2
5) How many time will be the finalize method is
executed?

It executed based on how many times the gc() method is


invoked. If we use gc() method 3 times, finalize() will also be
executed 3 times.

6) Syntax used to recieve and send the datagram


sockets
Receiving Datagram Sockets

Sending Datagram Sockets

DatagramSocket socket = new DatagramSocket();


byte[] buffer = data.getBytes();
InetAddress destinationAddress =
InetAddress.getByName(host);
DatagramPacket packet = new DatagramPacket(buffer,
buffer.length, destinationAddress, port);
socket.send(packet);

7) List the class and interface of the Threads

Java 2m 3
By extending Thread class.

class MyThread extends Thread

By implementing Runnable interface.

class ThreadUsingInterface implements Runnable

8) Difference between TCP and UDP


TCP

(i) The TCP/IP protocol is a set of protocols of four layers.


Overall, these four layers take the responsibility of the
communication process and end to end delivery of data, voice,
packets over the internet on inter and intra network.
(ii) The Transmission Control Protocol (TCP) works on the third
layer of this protocol model which is the transport layer.

UDP

(i) User Datagram Protocol (UDP) works on the transport layer


which is the third layer of the TCP/IP protocol suite. In contrast to
the TCP protocol, it is a connectionless protocol as it does not
establish a connection before sending the data over the network
for communication. (ii) User Datagram Protocol (UDP) also
works on the third layer of this protocol model which is the
transport layer

9) I/O packages types


Types

1. System.out: standard outputstream

2. System.in: standard inputstream

Java 2m 4
3. System.err : standard error stream

Java 2m 5

You might also like