Note 1

Take Note:

Take a note while surfing.

Note With Ink

Give your Note a Colorful Tag.

Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.

Think With Ink

Differ your Content by Color.

Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape

Note With Ink

Simple an Easy Way to take a note.

Easy to Access

Get the same in next visit.

Please wait...

JAVA Programming :: Basic Concepts

9. What will happen when you try to compile and run this code?

public class TGo implements Runnable{
public static void main(String argv[]){
TGo tg = new TGo();
Thread t = new Thread(tg);
public void run() {
while(true) {
System.out.println("looping while");

Answer: Option B

Explanation :

We will get a compile-time error in line no. 9, saying unreported exception InterruptedException; must be caught or declared to be thrown.

The sleep() method is responsible for generating the exception, and hence should be declared under try-catch block.

Hence, correct option is D.

Asked In :: Virtusa

Post Your Answer Here:     

Reply     |    Rate This: +0 -0      |     Report     |     To Reading List

Report Error

Please Login First Click Here