For the given code, if con is a valid Connection object, and the table Customer is empty, what will be output of this code?

try {
con = DriverManager.getConnection(url,uid,pwd);
Statement stmnt = con.createStatement();
rs = stmnt.executeQuery("select * from customer");
if (rs.next())
rs.getString(2);
} catch (SQLException e) {
e.printStackTrace();
}

Runtime exception at line 1 as getString(2) is not possible with the given select query

No exception , code runs fine

Runtime exception at line 1 as rs.next() will throw an exception

Compile time exception at line 1 as getString(2) is not possible with the given select query

Verified Answer
Correct Option - b

To get all Infosys Certified Java Programmer Exam questions Join Group https://bit.ly/infy_premium_group

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in