[Free] Download Latest (March 2016) Oracle 1Z0-804 Real Exam 91-100

Ensurepass

QUESTION 91

Given the code fragment:

 

clip_image002

 

Which code fragment inserted at line ***, enables the code to compile?

 

A.

public void process () throws FileNotFoundException, IOException { super.process ();

while ((record = br.readLine()) !=null) {

System.out.println(record);

}}

B.

public void process () throws IOException {

super.process ();

while ((record = br.readLine()) != null) {

System.out.println(record);

}}

C.

public void process () throws Exception {

super.process ();

while ((record = br.readLine()) !=null) {

System.out.println(record);

}}

D.

public void process (){

try {

super.process ();

while ((record = br.readLine()) !=null) {

System.out.println(record);

}

} catch (IOException | FileNotFoundException e) { } }

E.

public void process (){

try {

super.process ();

while ((record = br.readLine()) !=null) {

System.out.println(record);

}

} catch (IOException e) {}

}

 

Correct Answer: E

Explanation:

A: Compilation fails: Exception IOException is not compatible with throws clause in Base.process()

B: Compilation fails: Exception IOException is not compatible with throws clause in Base.process()

C: Compilation fails: Exception Exception is not compatible with throws clause in Base.process()

D: Compilation fails: Exception FileNotFoundException has already been caught by the alternative IOException Alternatives in a multi-catch statement cannot be related to subclassing Alternative java.io.FileNotFoundException is a subclass of alternative java.io.IOException

E: compiles …

 

 

QUESTION 92

Given:

 

clip_image004

 

What two changes should you make to apply the DAO pattern to this class?

 

A.

Make the Customer class abstract.

B.

Make the customer class an interface.

C.

Move the add, delete, find, and update methods into their own implementation class.

D.

Create an interface that defines the signatures of the add, delete, find, and update methods.

E.

Make the add, delete, and find, and update methods private for encapsulation.

F.

Make the getName and getID methods private for encapsulation.

 

Correct Answer: CD

Explanation:

C: The methods related directly to the entity Customer is moved to a new class.

D: Example (here Customer is the main entity):

public class Customer {

private final String id;

private String contactName;

private String phone;

public void setId(String id) { this.id = id; }

public String getId() { return this.id; }

public void setContactName(String cn) { this.contactName = cn;}

public String getContactName() { return

this.contactName; }

public void setPhone(String phone) { this.phone = phone; }

public String getPhone()

{ return this.phone; }

}

public interface CustomerDAO {

public void addCustomer(Customer c) throws DataAccessException;

public Customer getCustomer(String id)throws DataAccessException;

public List getCustomers() throws DataAccessException;

public void removeCustomer(String id) throws DataAccessException;

public void modifyCustomer(Customer c) throws

DataAccessException; }

Note: DAO Design Pattern

*Abstracts and encapsulates all access to a data source

*Manages the connection to the data source to obtainand store data

*Makes the code independent of the data sources and data vendors (e.g. plain-text, xml, LDAP, MySQL, Oracle, DB2)

 

clip_image006

 

 

QUESTION 93

Given the directory structure that contains three directories: company, Salesdat, and Finance:

 

Company

  Salesdat

 

* Target.dat

  Finance

 

* Salary.dat

 

* Annual.dat

 

And the code fragment:

 

clip_image008

 

If Company is the current directory, what is the result?

 

A.

Prints only Annual.dat

B.

Prints only Salesdat, Annual.dat

C.

Prints only Annual.dat, Salary.dat, Target.dat

D.

Prints at least Salesdat, Annual.dat, Salary.dat, Target.dat

 

Correct Answer: A

Explanation:

IF !! return FileVisitResult.CONTINUE;

The pattern *dat will match the directory name Salesdat and it will also match the file Annual.dat.

It will not be matched to Target.dat which is in a subdirectory.

 

 

QUESTION 94

The two methods of code reuse that aggregate the features located in multiple classes are ____________ ?

 

A.

Inheritance

B.

Copy and Paste

C.

Composition

D.

Refactoring

E.

Virtual Method Invocation

 

Correct Answer: AC

Explanation:

A: Inheritance is a way of reusing code and building bigger more functional objects from a basic object.

The original little object, the parent, is called the super-class. The more functional object that inherits from it iscalled the sub-class .

C: When your goal is code reuse, composition provides an approach that yields easier-to- change code.

 

 

QUESTION 95

Given the code fragment:

 

clip_image010

 

What is the result?

 

A.

getName (0): C:

subpath (0, 2): C:educationreport.txt

B.

getName(0): C:

subpth(0, 2): C:education

C.

getName(0): education

subpath (0, 2): educationinstitute

D.

getName(0): education

subpath(0, 2): educationinstitutestudent

E.

getName(0): report.txt

subpath(0, 2): insritutestudent

 

Correct Answer: C

Explanation:

Example:

Path path = Paths.get(“C:\home\joe\foo”);

getName(0) > home

subpath(0,2)

Reference: The Java Tutorial, Path Operations

 

 

QUESTION 96

Which two code blocks correctly initialize a Locale variable?

 

A.

Locale loc1 = “UK”;

B.

Locale loc2 = Locale.getInstance(“ru”);

C.

Locale loc3 = Locale.getLocaleFactory(“RU”);

D.

Locale loc4 = Locale.UK;

E.

Locale loc5 = new Locale(“ru”, “RU”);

 

Correct Answer: DE

Explanation:

The Locale class provides a number of convenient constants that you can use to create Locale objects forcommonly used locales.

For example, the following creates a Locale object for the United States:

Locale.US

E: Create a Locale object using the constructors in this class:

Locale(String language)

Locale(String language, String country)

Locale(String language, String country, String variant) Reference: java.utilClass Locale

 

 

QUESTION 97

Given:

 

clip_image012

 

What is the result?

 

A.

Compilation fails at line 9

B.

Compilation fails at line 10

C.

Compilation fails at line 5

D.

Compilation fails at line 3

E.

Compilation succeeds

 

Correct Answer: B

 

 

QUESTION 98

You have been asked to create a ResourceBundle file to localize an application. Which code example specifies valid keys menu1 and menu2 with values of File Menu and View Menu?

 

A.

<key name =”menu1″>File Menu</key>

<key name =”menu1″>View Menu</key>

B.

<key> menu1</key><File Menu>File Menu </value>

<key> menu1</key><File Menu>View Menu </value>

C.

menu1m File menu, menu2, view menu

D.

menu1 = File Menu

menu2 = View Menu

 

Correct Answer: D

Explanation:

A properties file is a simple text file. You can create and maintain a properties file with just aboutany 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. In the PropertiesDemo program the base name is LabelsBundle. Therefore the default properties file is called LabelsBundle.properties. The following examplefilecontains the following lines:

# This is the default LabelsBundle.properties file s1 = computer

s2 = disk

s3 = monitor

s4 = keyboard

Note that in the preceding file the comment lines begin with a pound sign (#). The other lines contain key-valuepairs. The key is on the left side of the equal sign and the value is on the right. For instance, s2 is the key thatcorresponds to the value disk. The key is arbitrary. We could have called s2 something else, like msg5 ordiskID. Once defined, however, the key should not change because it is referenced in the source code. Thevalues may be changed. In fact, when your localizers create new properties files to accommodate additionallanguages, they will translate the values into various languages.

 

 

QUESTION 99

Which method would you supply to a class implementing the Callable interface?

 

A.

callable ()

B.

executable ()

C.

call ()

D.

run ()

E.

start ()

 

Correct Answer: C

Explanation:

public interface Callable<V>

A task that returns a result and may throw an exception. Implementors define a single method with noarguments called call.

Note:

Interface Callable<V>

Type Parameters:

V – the result type of method call

The Callable interface is similar to Runnable, in that both are designed for classes whose instances arepotentially executed by another thread. A Runnable, however, does not return a result and cannot throw achecked exception.

The Executors class contains utility methods to convert from other common forms to Callable classes.

Reference: java.util.concurrent

 

 

 

 

QUESTION 100

Given:

 

clip_image014

 

What is the result?

 

A.

doc

B.

index.html

C.

an IllegalArgumentException is thrown at runtime.

D.

An InvalidPthException is thrown at runtime.

E.

Compilation fails.

 

Correct Answer: B

Explanation:

p.getName(int location) = returns path’ name element by index/location (starts with 0)

Example:

path = “project//doc//index.html”

p.getName(0) = project

p.getName(1) = doc

p.getName(2) = index.html

 

Free VCE & PDF File for Oracle 1Z0-804 Real Exam

Instant Access to Free VCE Files: CompTIA | VMware | SAP …
Instant Access to Free PDF Files: CompTIA | VMware | SAP …

This entry was posted in 1Z0-804 Real Exam (March 2016) and tagged , , , , , , , . Bookmark the permalink.