You are on page 1of 4

Object Cloning: For Cloning of an object we use Cloneable Interface

clone() is present in java.lang.Object class and it throw always


CloneNotSupportedException

Serializable: it is an empty interface(Marker Interface or Tag interface).

It is present in java.io.* package and it is used to convert my Objects into Byte


Stream.

Transient keyword: this keyword is mostly used with variables only.

Transient is used to stop the serialization on a variables.

Strictfp:(Strict Floating Point): for each and every OS the precision of a floating
value may vary from platform to platform.

so strictfp keyword is used to fix the precion for every OS.

and it is used with classes,methods and interface only.


it cannot be used with abstract class and variables.

Multithreading:

1) Multiple Thread executed simultaneouly

Thread is Light weight.

Thread share the same memory space.

Multitasking: Multiple task executed simultaneously

task is heviest weight

Multiprocessing:
Multiple Process executed simultaneously

Process share the different memory space

process is heavy weight.

Life Cycle of Thread:

1) New
2) runnable
3) Running
4) Non-Runnable
5) Terminate

Creating a thread

1) By extending thread class


2) by implement runnable interface
Q) can java thread object invoke java thread object twice?
Ans No, a thread call the start method only once.

Q) Difference between Preemtive Scheduling and time -Slicing

Preemtive Scheduling: the high priority thread will go into execution and complete
the task, if another higher priority thread comes in a queue then the first thread
will be in waiting state and other thread will go into execution and so on.

Time Slicing:

In this each and every thread get one time if that thread complete the task in that
time which is assigned then it will enter into terminate state otherwise that
thread will come again in a queue.

main() is the high priority and its max priority is 10.

Min Priority ---- 1


Normal Priority--- 5

Thread Schedular decide the priority of the thread.


it is pool of threads if any user give the max priority to any thread then again
Thread Schedular will define their own priority to that thread.

Join():

join() work on the thread and it give priority to the thread for complete their
task.

Join() work until that thread will enter into terminate state.
in other word it causes the other thread to be in waiting state until the join
thread complete the task.

Naming a Thread:

1) setName()
2) getName()

CurrentThread:

CurrentThread().

What is Daemon Thread:

It is a low priority thread and used to perform the background supporting task for
the user.
Its life depend on user thread.

If there is no user thread then JVM will delete the Daemon thread.
Example : finalize() and gc() is a daemon thread.
Difference between wait and sleep method?

Sleep() : sleep the thread for a specific time if tht time over thread will the
resource and complete the work.

wait(): the thread will be in waiting state until the next thread call notify();

notify(): release the resourse and provide to the wait thread.