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:

Which is true?

A) "X extends Y" is correct if and only if X is a class and Y is an interface B) "X extends Y" is correct if and only if X is a class and Y is an interface
C) "X extends Y" is correct if X and Y are either both classes or both interfaces D) "X extends Y" is correct for all combinations of X and Y being classes and/or interfaces
 
Answer & Explanation Answer: C) "X extends Y" is correct if X and Y are either both classes or both interfaces

Explanation:

A is incorrect because classes implement interfaces, they don't extend them. B is incorrect because interfaces only "inherit from" other interfaces. D is incorrect based on the preceding rules.

Report Error

View Answer Report Error Discuss

Filed Under: Java

2 6026
Q:

Which key word is to be used to tell the JVM to skip the variable while performing the serialization process of the object containing it?

A) Transcient B) Volatile
C) Static D) Final
 
Answer & Explanation Answer: A) Transcient

Explanation:

If you mark an instance variable as transient, you're telling the JVM to skip (ignore) this variable when you attempt to serialize the object containing it.

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 2385
Q:

The keyword which indicates that a method can be accessed by only one thread at a time is

A) Strictfp B) Synchronized
C) New D) None
 
Answer & Explanation Answer: B) Synchronized

Explanation:

The synchronized keyword indicates that a method can be accessed by only one thread at a time

Report Error

View Answer Report Error Discuss

Filed Under: Java

2 3284
Q:

In a single virtual machine, the Java programming language passes arguments by

A) Refference B) Value
C) Both A and B D) None
 
Answer & Explanation Answer: B) Value

Explanation:

In single virtual machine,JVM passes arguments only by value.

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 2178
Q:

Which of the following is not used for commenting in java?

A) // B) /* */
C) /** */ D) /** **/
 
Answer & Explanation Answer: D) /** **/

Explanation:
  • //               is a single line comment
  • /*  */          is commenting on one or more lines
  • /** */         is documentation comment
Report Error

View Answer Report Error Discuss

Filed Under: Java

1 3161
Q:

Which of the following is not the other name of attriibute?

A) Data member B) Instance variable
C) instance D) Data filed
 
Answer & Explanation Answer: C) instance

Explanation:

Instance is an object not an attribute

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 2195
Q:

There is one default constructor in every class.

A) The above statement is true B) The above statement is false
C) Both true and false D) None
 
Answer & Explanation Answer: A) The above statement is true

Explanation:

There will always be a default constructor in every class 

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 3272
Q:

Client code having direct access to internal data is called

A) Encapsulation B) DataHiding
C) Polymorphism D) DataAbstraction
 
Answer & Explanation Answer: B) DataHiding

Explanation:

Client code must use setters and getters to access internal data in DataHiding

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 2015