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 a ResultSet ?

Answer

A table of data representing a database result set, which is usually generated by executing a statement that queries the database.


 


ResultSet object maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. The next method moves the cursor to the next row, and because it returns false when there are no more rows in the ResultSet object, it can be used in a while loop to iterate through the result set.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1667
Q:

What is DriverManager ?

Answer

DriverManager is a class in java.sql package. It is the basic service for managing a set of JDBC drivers.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1820
Q:

What are the steps required to execute a query in JDBC?

Answer

First we need to create an instance of a JDBC driver or load JDBC drivers, then we need to register this driver with DriverManager class. Then we can open a connection. By using this connection , we can create a statement object and this object will help us to execute the query.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1757
Q:

What is JDBC Driver ?

Answer

The JDBC Driver provides vendor-specific implementations of the abstract classes provided by the JDBC API. This driver is used to connect to the database.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1618
Q:

What is JDBC ?

Answer

JDBC technology is an API (included in both J2SE and J2EE releases) that provides cross-DBMS connectivity to a wide range of SQL databases and access to other tabular data sources, such as spreadsheets or flat files. With a JDBC technology-enabled driver, you can connect all corporate data even in a heterogeneous environment.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1706
Q:

How to identify a given positive decimal number as even/odd without using % or / operator ?

Answer

You may be very good at coding,but if you questioning how on earth you could solve this problem.Then here is a solution. If you remember the good old days of our primary school then the solution is easy,"division is a matter of iterative subtraction".


public class TestEvenOdd {
public static void main(String arg[ ]){
int num=6;
int result=num;
while(result>=2){
result=result-2;
}
if(result==1){
System.out.println("The number is odd");
}else{
System.out.print("The number is even");
}
}
}

Report Error

View answer Workspace Report Error Discuss

Subject: Java

3 5238
Q:

What will be the output of the following code snippet?

Object s1 = new String("Hello");
Object s2 = new String("Hello");
 
if(s1 == s2) {
  System.out.println("s1 and s2 are ==");
}else if (s1.equals(s2)) {
  System.out.println("s1 and s2 are equals()");
}

Answer

Answer : s1 and s2 are equals()


 


Explanation :



 

Report Error

View answer Workspace Report Error Discuss

Subject: Java

8 16044
Q:

What is classloader?

Answer

The classloader is a subsystem of JVM that is used to load classes and interfaces.There are many types of classloaders e.g. Bootstrap classloader, Extension classloader, System classloader, Plugin classloader etc.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1874