Set - 1

Question 31 :

What would you use to compare two String variables - the operator == or the method equals()?

Answer :

I'd use the method equals() to compare the values of the Strings and the == to check if two variables point at the same instance of a String object.

Question 32 :

What is thread?

Answer :

A thread is an independent path of execution in a system.

Question 33 :

What is multi-threading?

Answer :

Multi-threading means various threads that run in a system.

Question 34 :

How does multi-threading take place on a computer with a single CPU?

Answer :

The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.

Question 35 :

How to create a thread in a program?

Answer :

You have two ways to do so. First, making your class "extends" Thread class. Second, making your class "implements" Runnable interface. Put jobs in a run() method and call start() method to start the thread.