Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

If two objects o1 and o2 are equal, what are the values for o1, equals(o2) and o

ID: 3834189 • Letter: I

Question

If two objects o1 and o2 are equal, what are the values for o1, equals(o2) and o1, hashCode() == o2.hashCode()? true true true false false true false false Result set meta data are retrieved through ______. a Connection object a Statement object a ResultSet Object a PreparedStatement object Given the following code snippet that uses JDBC to create a database connection: String driver = "org.apache.derby.jdbc.EmbeddedDriver"; String url = "jdbc:derby:Test;create=true"; String user = ""; String pw = ""; Class.forName(driver) ; Connection conn = DriverManager.getConnection(url, user, pw) ; What is the name of the database that this code fragment connects to?

Explanation / Answer

Q1. if two objects o1 and o2 are equal, what are the values for o1.equals(o2) and o1.hashCode() == o2.hashCode()
Answer : True True
if o1.equals(o2) is true, then o1.hashCode() == o2.hashCode() is also true
Explanation :
.equals is used to evaluate the value of an object. When objects are hashed, their numerical values on a systems level are used to produce a hash code (an integer, if you will). If the objects are the exact same (e.g. in terms of attributes), they will have the same numerical sequence and therefore hash to the same value.

Q2. Result set meta data are retrieved through_____
Answer : A ResultSet Object
Ex.
PreparedStatement ps=con.prepareStatement("select * from emp");
ResultSet rs=ps.executeQuery();
ResultSetMetaData rsmd=rs.getMetaData();

Q3. What is the name of the database that this code fragment connects to ?
Answer : h2database which is provided by Apache foundation.

Thanks...