6
Q:

void waitForSignal() {

Object obj = new Object();

synchronized (Thread.currentThread()) {

obj.wait();

obj.notify();

}

}

Which statement is true?

A) This code can throw an InterruptedException. B) This code can throw an IllegalMonitorStateException.
C) This code can throw a TimeoutException after ten minutes D) All the above

Answer:   B) This code can throw an IllegalMonitorStateException.



Explanation:

It will throw  IllegalMonitorStateException.

Subject: Java
Job Role: IT Trainer
Q:

How to do MultiThreading in Java?

Answer

To do multi threading in java we use interfaces and classes defined in java.lang package.


Those classes and interfaces are:


Java.lang.Runnable, Java.lang. Thread, Java.lang.ThreadGroup

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1788
Q:

What is MultiThreading?

Answer

Executing two or more blocks (threads) of a program at a time is called MultiThreading.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2214
Q:

What is MultiTasking?

Answer

Executing more than one program simultaniously.(i.e at time)


Ex:


Windows media player  is a program


Internet explorer(IE) is another program executing both the programs  at a time is called multi tasking.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2087
Q:

What is Thread?

Answer

A Thread is a block of code that can be executed in parallel with another block of code.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2339
Q:

How to get contents of the folder?

Answer

File[] listFiles();


this method returns list of files stored in a directory.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1694
Q:

How to get last modified date of a file?

Answer

long lastModified();


we can give this return value to a date object and we can get data to be displayed.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1627
Q:

How to check that whether the file object is pointing a folder or not?

Answer

boolean isDirectory();

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1786
Q:

How to check that the file object is pointing a file on HD?

Answer

boolean isFile();

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1670