Question-81. What is type casting ?

Answer- Type casting means treating a variable of one type as though it is another type.

Question-82. Describe the lifecycle of a thread ?

Answer- A thread is a execution in a program. The life cycle of a thread include −

• Newborn state
• Runnable state
• Running state
• Blocked state
• Dead state

 

Question-83. Does Java allow Default Arguments ?

Answer- No, Java does not allow Default Arguments.

Question-84. Define Network Programming ?

Answer- It refers to writing programs that execute across multiple devices (computers), in which the devices are all connected to each other using a network.

Question-85. What is Socket ?

Answer- Sockets provide the communication mechanism between two computers using TCP. A client program creates a socket on its end of the communication and attempts to connect that socket to a server.

Question-86. Advantages and Disadvantages of Sockets ?

Answer-

Advantages: Sockets are flexible and sufficient. Efficient socket based programming can be easily implemented for general communications. It cause low network traffic.
Disadvantages: Socket based communications allows only to send packets of raw data between applications. Both the client-side and server-side have to provide mechanisms to make the data useful in any way.

 

Question-87. Which class is used by server applications to obtain port and listen to client requests ?

Answer- java.net.ServerSocket class is used by server applications to obtain a port and listen for client requests

Question-88. Why Generics are used is Java ?

Answer- Generics provide compile-time type safety that allows programmers to catch invalid types at compile time. Java Generic methods and generic classes enable programmers to specify, with a single method declaration, a set of related methods or, with a single class declaration, a set of related types.

Question-89. What is daemon thread ?

Answer- Daemon thread is a low priority thread, which runs intermittently in the back ground doing the garbage collection operation for the java runtime system.

Question-90. Which method is used to create daemon thread? ?

Answer- setDaemon method is used to create a daemon thread.