Premium

Oracle Advacned Java Advanced Certification Questions and Answers (Dumps and Practice Questions)



Question : Which one of the following statements is a correct way to instantiate a Statement object?


 : Which one of the following statements is a correct way to instantiate a Statement object?
1. Statement statement = connection.getStatement();

2. Statement statement = connection.createStatement();

3. Access Mostly Uused Products by 50000+ Subscribers

4. Statement statement = connection.getStatementInstance();


Correct Answer : Get Lastest Questions and Answer :
Explanation: : java.sql.Connection

A connection (session) with a specific database. SQL statements are executed and results are returned within the context of a connection.
A Connection object's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, and so on.
This information is obtained with the getMetaData method.
Note: When configuring a Connection, JDBC applications should use the appropriate Connection method such as setAutoCommit or setTransactionIsolation. Applications should not invoke
SQL commands directly to change the connection's configuration when there is a JDBC method available. By default a Connection object is in auto-commit mode, which means that it
automatically commits changes after executing each statement. If auto-commit mode has been disabled, the method commit must be called explicitly in order to commit changes;
otherwise, database changes will not be saved.
A new Connection object created using the JDBC 2.1 core API has an initially empty type map associated with it. A user may enter a custom mapping for a UDT in this type map. When a
UDT is retrieved from a data source with the method ResultSet.getObject, the getObject method will check the connection's type map to see if there is an entry for that UDT. If so,
the getObject method will map the UDT to the class indicated. If there is no entry, the UDT will be mapped using the standard mapping.
A user may create a new type map, which is a java.util.Map object, make an entry in it, and pass it to the java.sql methods that can perform custom mapping. In this case, the method
will use the given type map instead of the one associated with the connection.
For example, the following code fragment specifies that the SQL type ATHLETES will be mapped to the class Athletes in the Java programming language. The code fragment retrieves the
type map for the Connection object con, inserts the entry into it, and then sets the type map with the new entry as the connection's type map.
java.util.Map map = con.getTypeMap();
map.put("mySchemaName.ATHLETES", Class.forName("Athletes"));
con.setTypeMap(map);





Question : Which one of the following statements is true with respect to ResultSet?


 : Which one of the following statements is true with respect to ResultSet?
1. Calling absolute(1) on a ResultSet instance is equivalent to calling
first(), and calling absolute(-1) is equivalent to calling last().

2. Calling absolute(0) on a ResultSet instance is equivalent to calling
first(), and calling absolute(-1) is equivalent to calling last().

3. Access Mostly Uused Products by 50000+ Subscribers
first(), and calling absolute(0) is equivalent to calling last().

4. Calling absolute(1) on a ResultSet instance is equivalent to calling
first(), and calling absolute(0) is equivalent to calling last().


Correct Answer : Get Lastest Questions and Answer :
Explanation: Calling absolute(1) on a ResultSet instance is equivalent to calling first(), and calling absolute(-1) is equivalent to calling last().




Question : Please map below statements makes use of a factory method?

A. Locale locale1 = new Locale("en", "", "");
B. NumberFormat.getInstance(Locale.INDIA);
C. Locale locale3 = new Locale.Builder().setLanguageTag("en").build();
D. Date today = new Date();

1. Factory Method
2. Constructor instantiation
3. Access Mostly Uused Products by 50000+ Subscribers

 : Please map below statements makes use of a factory method?
1. 1-A, 2- B and D, 3-C
2. 1-B and D, 2- A, 3-C
3. Access Mostly Uused Products by 50000+ Subscribers
4. 1-B, 2- A , 3-C and D
5. 1-A and D, 2- D, 3-C

Correct Answer : Get Lastest Questions and Answer :
Explanation: Exp: Factory Method
. Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
. Defining a "virtual" constructor.
. The new operator considered harmful.

Related Questions


Question : You have been given below code,

Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT * FROM table"));
int columnCount = resultSet.getMetaData().getColumnCount();

Select the correct statement, which applies?
A. Table header can be accessed using 0th Index.
B. Table header can be accessed using 1st Index
C. MetaData object cannot return number of columns in query.
D. A and C
E. B and C

 : You have been given below code,
1. Table header can be accessed using 0th Index.

2. Table header can be accessed using 1st Index

3. Access Mostly Uused Products by 50000+ Subscribers

4. A and C

5. B and C



Question : You have been given below code, once you execute it what will be the expected result?

package com.hadoopexam;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

class Welcome {
public static void main(String[] args) {
Connection connection=null;
try (Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT * FROM User")) {
System.out.println(resultSet.getInt("user_id") + "\t"
+ resultSet.getString("UserName") + "\t"
+ resultSet.getString("lastName") + "\t"
+ resultSet.getString("emailId") + "\t"
+ resultSet.getString("Cell"));
} catch (SQLException sqle) {
System.out.println("SQLException");
}
}
}

 : You have been given below code, once you execute it what will be the expected result?
1. It will give compile time error

2. It will give runtime error

3. Access Mostly Uused Products by 50000+ Subscribers

4. It will compile and run and print nothing.



Question : Select the correct statement with regards to JDBC Statement interface

 : Select the correct statement with regards to JDBC Statement interface
1. The Statement interface and its derived interfaces implement the AutoCloseable interface, hence Statement objects can be used with the try with- resources
statement.

2. You can use PreparedStatement is used to execute stored procedures

3. Access Mostly Uused Products by 50000+ Subscribers

4. A and C

5. B and C



Question : Which one of the following statements is a correct way to instantiate a Statement object?


 : Which one of the following statements is a correct way to instantiate a Statement object?
1. Statement statement = connection.getStatement();

2. Statement statement = connection.createStatement();

3. Access Mostly Uused Products by 50000+ Subscribers

4. Statement statement = connection.getStatementInstance();



Question : Which one of the following statements is true with respect to ResultSet?


 : Which one of the following statements is true with respect to ResultSet?
1. Calling absolute(1) on a ResultSet instance is equivalent to calling
first(), and calling absolute(-1) is equivalent to calling last().

2. Calling absolute(0) on a ResultSet instance is equivalent to calling
first(), and calling absolute(-1) is equivalent to calling last().

3. Access Mostly Uused Products by 50000+ Subscribers
first(), and calling absolute(0) is equivalent to calling last().

4. Calling absolute(1) on a ResultSet instance is equivalent to calling
first(), and calling absolute(0) is equivalent to calling last().



Question : Please map below statements makes use of a factory method?

A. Locale locale1 = new Locale("en", "", "");
B. NumberFormat.getInstance(Locale.INDIA);
C. Locale locale3 = new Locale.Builder().setLanguageTag("en").build();
D. Date today = new Date();

1. Factory Method
2. Constructor instantiation
3. Access Mostly Uused Products by 50000+ Subscribers

 : Please map below statements makes use of a factory method?
1. 1-A, 2- B and D, 3-C
2. 1-B and D, 2- A, 3-C
3. Access Mostly Uused Products by 50000+ Subscribers
4. 1-B, 2- A , 3-C and D
5. 1-A and D, 2- D, 3-C