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:

Why is the main() method declared static?

Answer

main() method is called by the JVM even before the instantiation of the class, hence it is declared as static.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2164
Q:

What are instance variables?

Answer Instance variables are those which are defined at the class level. Instance variables need not be initialized before using them as they are automatically initialized to their default values.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2089
Q:

Is Java a pure object oriented language?

Answer

Java uses primitive data types and hence is not a pure object oriented language.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 2244
Q:

Are arrays primitive data types?

Answer In Java, Arrays are objects.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1958
Q:

Does Java support multiple inheritance?

Answer Java doesn't support multiple inheritance.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2965
Q:

What is difference between Path and Classpath?

Answer

PATH and CLASSPATH are operating system level environment variables. PATH is used to define where the system can find the executables (.exe) files whereas CLASSPATH is used to specify the location of .class files.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 3218
Q:

What do you mean by platform independence?

Answer

Platform independence means that we can write and compile the java code in one platform (Eg Windows) and can execute the class in any other supported platform (Eg Linux,Solaris,etc).

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 3313
Q:

What is the difference between a JDK and a JVM?

Answer

JDK is Java Development Kit which is for development purpose and it includes execution environment also.


JVM is Java Virtual Machine which is a run time environment for the compiled java class files .Hence you will not be able to compile your source files using a JVM.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2843