Oracle 1Z0-805 Online Practice
Questions and Exam Preparation
1Z0-805 Exam Details
Exam Code
:1Z0-805
Exam Name
:Upgrade to Java SE 7 Programmer
Certification
:Oracle Certifications
Vendor
:Oracle
Total Questions
:90 Q&As
Last Updated
:Dec 09, 2021
Oracle 1Z0-805 Online Questions &
Answers
Question 31:
Which two statements are true about RowSet subinterfaces?
A. A jdbcRowSet object provides a JavaBean view of a result set. B. A cachedRowSet provides a connected view of the database. C. A FilteredRowSet object filter can be modified at any time. D. A webRowSet returns JSON-formatted data.
A. A jdbcRowSet object provides a JavaBean view of a result set. C. A FilteredRowSet object filter can be modified at any time.
A:JdbcRowSet Mmakes results available as a JavaBean component
C: FilteredRowSetimplements lightweight querying, usingjavax.sql.rowset.Predicate The predicate set on a FilteredRowSet object applies a criterion on all rows in a RowSet object to manage a subset of rows in aRowSet object. This criterion governs the subset of rows that are visible and also defines which rows can be modified, deleted or inserted. Therefore, the predicate set on a FilteredRowSet object must be considered as bi-directional and the set criterion as the gating mechanism for all views and updates to the FilteredRowSet object. Any attempt to update the FilteredRowSet that violates the criterion will result in a SQLException object being thrown. The FilteredRowSet range criterion can be modified by applying a new Predicate object to the FilteredRowSet instance at any time. This is possible if no additional references to the FilteredRowSet object are detected. A new filter has has an immediate effect on criterion enforcement within the FilteredRowSet object, and all subsequent views and updates will be subject to similar enforcement.
Note: The RowSet interface, a subinterface of ResultSet , was introduced with JDBC 2. Because a RowSet is a ResultSet , you can use any of the ResultSet processing methods previously discussed. But RowSet s tend to be more self-
contained; you typically do not need to specify a driver, and performing queries is done in a new way. You call setCommand() to specify the query and execute() to perform the query (this takes the place of creating a Statement and calling its
executeQuery() method).
Incorrect answer:
B: CachedRowSetcaches results in memory; disconnected Rowset.
D:WebRowSet converts between XML data and RowSet. The data is not JSON formatted.
Note: JSON or JavaScript Object Notation, is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript scripting language for representing simple data structures and associative arrays, called objects. Despite its relationship to JavaScript, it is language-independent, with parsers available for many languages.
Question 32:
Given:
public class SampleClass {
public static void main(String[] args)
{ SampleClass sc = new
SampleClass(); sc.processCD();
}
private void processCD() {
try (CDStream cd = new CDStream()) {
cd.open();
cd.read();
cd.write("lullaby");
cd.close();
} catch (Exception e)
{ System.out.println("Exception
thrown");
}
}
class CDStream {
String cdContents = null;
public void open()
{ cdContents = "CD
Contents";
System.out.println("Opened CD stream");
}
public String read() throws Exception {
throw new Exception("read error");
}
public void write(String str)
{ System.out.println("CD str is: " +
str);
}
public void close() {
cdContents = null;
}
What is the result?
A. Compilation CD stream B. Opened CD thrown C. Exception thrown D. Opened CD stream CD str is: lullaby
A. Compilation CD stream
In this example the compilation of line " try (CDStream cd = new CDStream()) {" will fail, as try-with-resources not applicable to variable type CDStream.
Note: The try-with-resources statement is a try statement that declares one or more resources. A resource is an object that must be closed after the program is finished with it. The try-with- resources statement ensures that each resource is closed at the end of the statement. Any object that implements java.lang.AutoCloseable, which includes all objects which implement java.io.Closeable, can be used as a resource.
Reference: The Java Tutorials,The try-with-resources Statement
Question 33:
Consider the following five methods:
Which method should you use to connect to a java Db database with JDBC 4.0, but not with previous versions of JDBC?
A. getConnectionA B. getConnectionB C. getConnectionC D. getConnectionD E. getConnectionE
D. getConnectionD
Note on D not E: Prior to JDBC 4.0, we relied on the JDBC URL to define a data source connection. Now with JDBC 4.0, we can get a connection to any data source by simply supplying a set of parameters (such as host name and port
number) to a standard connection factory mechanism. New methods were added to Connection and Statement interfaces to permit improved connection state tracking and greater flexibility when managing Statement objects in pool
environments.
Note on that an embedded driver is no longer needed(not A, B, C):
Thanks to the Java SE Service Provider mechanism included in Mustang, Java developers no longer need to explicitly load JDBC drivers using code like Class.forName() to register a JDBC driver. The DriverManager class takes care of this
by automatically locating a suitable driver when the DriverManager.getConnection() method is called. This feature is backward-compatible, so no changes are needed to the existing JDBC code.
In JDBC 4.0, we no longer need to explicitly load JDBC drivers using Class.forName(). When the method getConnection is called, the DriverManager will attempt to locate a suitable driver from among the JDBC drivers that were loaded at
initialization and those loaded explicitly using the same class loader as the current application.
Assume that we need to connect to an Apache Derby database, since we will be using this in the sample application explained later in the article:
DriverManager.getConnection(jdbcUrl, jdbcUser, jdbcPassword); But in JDBC 4.0, we don't need the Class.forName() line. We can simply call getConnection() to get the database connection.
Question 34:
Given a language code of fr and a country code of FR, while file name represents a resource bundle file name that is not the default?
A. MessageBundle_fr_FR.properties B. MessageBundle_fr_FR.Profile C. MessageBundle_fr_FR.Xml D. MessageBundle_fr_FR.Java E. MessageBundle_fr_FR.locale
A. MessageBundle_fr_FR.properties
A properties file is a simple text file. You can create and maintain a properties file with just about any text editor.
You should always create a default properties file. The name of this file begins with the base name of your ResourceBundle and ends with the .properties suffix. To support an additional Locale, your localizers will create a new properties file
that contains the translated values. No changes to your source code are required, because your program references the keys, not the values.
For example, to add support for the German language, your localizers would translate the values in LabelsBundle.properties and place them in a file named LabelsBundle_de.properties. Notice that the name of this file, like that of the default
file, begins with the base name LabelsBundle and ends with the .properties suffix.
Reference: The Java Tutorials,Backing a ResourceBundle with Properties Files
A. The report.tmp file is purged during reboot. B. The report.tmp file is automatically purged when it is closed. C. The report.tmp file exists until it is explicitly deleted. D. The report.tmp file is automatically purged when the execution of the program completes.
C. The report.tmp file exists until it is explicitly deleted.
The createTempFile (String prefix,
String suffix,
FileAttribute>... attrs) method creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name.
This method is only part of a temporary-file facility. Where used as a work files, the resulting file may be opened using the DELETE_ON_CLOSE option so that the file is deleted when the appropriate close method is invoked. Alternatively, a
shutdown-hook, or the File.deleteOnExit() mechanism may be used to delete the file automatically.
In this scenario no delete mechanism is specified.
Reference: java.nio.file.createTempFile
Question 36:
Given the code fragment: String query = "SELECT ID FROM Employee"; \\ Line 1 try (Statement stmt = conn.CreateStatement()) { \\ Line 2 ResultSet rs = stmt.executeQuery(query); \\ Line 3 stmt.executeQuery ("SELECT ID FROM Customer"); \\ Line 4 while (rs.next()) { \\process the results
Assume that the SQL queries return records. What is the result of compiling and executing this code fragment?
A. The program prints employees IDs. B. The program prints customer IDs. C. The program prints Error. D. Compilation fails on line 13.
A. The program prints employees IDs.
Line 3 sets the resultset rs. rs will contain IDs from the employee table. Line 4 does not affect the resultset rs. It just returns a resultset (which is not used).
Note:
A ResultSet object is a table of data representing a database result set, which is usually generated by executing a statement that queries the database.
You access the data in a ResultSet object through a cursor. Note that this cursor is not a database cursor. This cursor is a pointer that points to one row of data in the ResultSet. Initially, the cursor is positioned before the first row. The method
ResultSet.next moves the cursor to the next row. This method returns false if the cursor is positioned after the last row. This method repeatedly calls the ResultSet.next method with a while loop to iterate through all the data in the ResultSet.
Reference: The Java Tutorials,Retrieving and Modifying Values from Result Sets
Question 37:
Given:
public static void main(String[] args) throws Exception {
try {
processFile();
} catch(Exception e) {
Throwable [] t = e.getSuppressed();
}
}
public static void processFile() throws IOException
{ try (FileReader fr = new FileReader"logfilesrc.txt");
FileWriter fw = new FileWriter("logfiledest.txt")) {{
java.util.zip.ZipFile zf = new java.util.zip.ZipFile("alllogs.zip");
System.out.println("Created files for logs");
}
}
The getSuppressed method returns an array of .
A. Allexceptions that were thrown in the processFile method but were suppressed. B. Exceptions suppressed because that are not declared in the throws clause. C. Only runtime exceptions that were thrown in the processFile method but were suppressed. D. Only runtime exceptions that were thrown in the processFile method but were not declared in throws clause.
A. Allexceptions that were thrown in the processFile method but were suppressed.
The GetSuppressed() methodreturns an array containing all of the exceptions that were suppressed, typically by the try-with-resources statement, in order to deliver this exception. If an exception is thrown from the try block and one or more exceptions are thrown from the try- with-resources statement, then those exceptions thrown from the try-with-resources statement are suppressed. Reference: The Java Tutorials,Suppressed Exceptions
Question 38:
Which two scenarios throw FileSystemNotFoundException when the paths.get(URI) method is invoked?
A. When preconditions on the uri parameter do not hold B. When the provider identified by the URI'S scheme component is not installed C. When a security manager is installed and it denies an unspecified permission to acess the file system. D. When the file system identified by the uri does not exist and cannot be created automatically E. When the path string cannot be converted to a Path
B. When the provider identified by the URI'S scheme component is not installed D. When the file system identified by the uri does not exist and cannot be created automatically
The file system, identified by the URI, does not exist and cannot be created automatically, or the provider identified by the URI's scheme component is not installed.
Note: This method converts the given URI to a Path object.
It throws the following exceptions:
*IllegalArgumentException - if preconditions on the uri parameter do not hold. The format of the URI is provider specific.
*FileSystemNotFoundException - The file system, identified by the URI, does not exist and cannot be created automatically, or the provider identified by the URI's scheme component is not installed *SecurityException - if a security manager
is installed and it denies an unspecified permission to access the file system
Reference: java.nio.file.Paths
Question 39:
Given:
Person
public Person(int id)
public int getid()
public String getContactDetails()
public void setContactDetails(String contactDetails)
public String getName()
public void setName(String name)
public Person getPerson(int id) throws Exception
public void createPerson(int id) throws Exception
public Person deletePerson(int id) throws Exception
public void updatePerson(Person p) throws Exception
Which group of methods is moved to a new class when implementing the DAO pattern?
A. public int getId () public String getContractDetails () public void setContactDetails (String ContactDetails) public void getName () public Person setName (String name) B. public int getId () public String getContractDetails () public void getName () public person getPerson (int id) throws Exception C. public void setContactDetails(String contactDetails) public void setName (String name) D. public person getPerson(int id) throws Exception public void createPerson (person p) throws exception public void deleteperson(int id) throws Exception public void updatePerson (Person p) throws Exception
D. public person getPerson(int id) throws Exception public void createPerson (person p) throws exception public void deleteperson(int id) throws Exception public void updatePerson (Person p) throws Exception
Note:Data Access Object
Abstracts and encapsulates all access to a data source
Manages the connection to the data source to obtain and store data Makes the code independent of the data sources and data vendors (e.g. plain-text, xml, LDAP, MySQL, Oracle, DB2)
Question 40:
Given:
ConcurrentMap partList = new ConcurrentHashMap<> ();
Which fragment puts a key/value pair in partList without the possibility of overwriting an existing key?
A. partList.put (key,"Blue Shirt"); B. partList.putAbsent(key,"Blu Shirt") C. partList.putIfNotLocked (key,"Blue Shirt"); D. partList.putAtomic (key,"Blue Shirt"); E. if (!partlist.containsKey(key)) partList.put(key,"Blue Shirt");
E. if (!partlist.containsKey(key)) partList.put(key,"Blue Shirt");
The containsKey method returns true if this map maps one or more keys to the specified value.
So this statement adds a new key if they key is not present.
Nowadays, the certification exams become more and more important and required by more and more
enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare
for the exam in a short time with less efforts? How to get a ideal result and how to find the
most reliable resources? Here on Vcedump.com, you will find all the answers.
Vcedump.com provide not only Oracle exam questions,
answers and explanations but also complete assistance on your exam preparation and certification
application. If you are confused on your 1Z0-805 exam preparations
and Oracle certification application, do not hesitate to visit our
Vcedump.com to find your solutions here.