8
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:

What is the security mechanism used in java?

Answer

Java uses sand box security model.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1572
Q:

What is diamond problem?

Answer

The diamond problem is an ambiguity that can occur when a class multiply inherits from two classes that both descend from a common super class

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1864
Q:

What is the difference between array and ArrayList ?

Answer

Array is collection of same data type. Array size is fixed, It cannot be expanded.


 


But ArrayList is a growable collection of objects.ArrayList is a part of Collections Framework and can work with only objects.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1555
Q:

How will you define an abstract class?

Answer

An abstract class is defined with the keyword abstract Eg:
public abstract class MyClass { }

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1446
Q:

What is an abstract class?

Answer

An abstract class is an incomplete class. An abstract class is defined with the keyword abstract . We cannot create an object of the abstract class because it is not complete. It sets a behavioral protocol for all its child classes.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1713
Q:

What is the difference between a constructor and a method?

Answer

A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator. We cannot invoke a constructor directly.


 


A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1995
Q:

What is a class, member and local variable?

Answer

Variables declared within a method are local variables. Variables declared within the class are member variables.  Variables declared within the class with static modifier are class variables 

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1491
Q:

What is polymorphism?

Answer

It is the ability of an object to behave differently on different situations for the same message.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1687