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 create Directory on the HD?

Answer

To create directory on the HD we use mkDir() method:


boolean mkDir();


This method returns true if the directory is created on HD


This method returns false if the directory is already existing on HD

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1784
Q:

How to create a file on the hard disk by using File class object?

Answer

We can use the following method call:


boolean createNewFile();


This method creates a new file on the HD. 


 


If a file is already existing with the name given in the constructor then this method does not creates file on HD.


If file is successfully created then this method returns true.


If file is already existing on the HD then this method returns false.


This method may throw IOException whenever IO error is generated while creating file on HD.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1623
Q:

Why interface data is public?

Answer

to access non-public data outside class getter methods be defined but we cannot define a  method inside interface we can declared a method inside interface.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 4391
Q:

Why interface data is final?

Answer

bcoz interface does not contains any initializers and constructors to initialize its data members.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1891
Q:

Why interface data is static?

Answer

Interface data is static data why bcoz interface supports multiple inheritance.


if inteface data is non-static then there is chance for replication of the data (bcoz of replication of data ambiguity problem occurs )

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1671
Q:

What is abstract method?

Answer

abstract method is a method declared with abstract modifier but  with out body.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1751
Q:

why protected modifier?

Answer

Outside the package if any other class other than JVM calls the finalize method our class then it is not allowed

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2052
Q:

What is the use of tostring() method?

Answer

If we print any object by using println() or print() methods.


The println() or print() methods internally calls tostring() method and prints the return value of toString() method.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1639