Up to the immediate present Oracle 1Z0-804 exam

It is more faster and easier to pass the Oracle 1Z0-804 exam by using Precise Oracle Java SE 7 Programmer II Exam questuins and answers. Immediate access to the Improved 1Z0-804 Exam and find the same core area 1Z0-804 questions with professionally verified answers, then PASS your exam with a high score now.


2024 Oracle Official New Released 1Z0-804 ♥♥
https://www.certleader.com/1Z0-804-dumps.html


Q1. Which two forms of abstraction can a programmer use in Java? 

A. enums 

B. interfaces 

C. primitives 

D. abstract classes 

E. concrete classes 

F. primitive wrappers 

Answer: B,D 

Explanation: 

When To Use Interfaces An interface allows somebody to start from scratch to implement your interface or implement your interface insome other code whose original or primary purpose was quite different from your interface. To them, yourinterface is only incidental, something that have to add on to thetheir code to be able to use your package. Thedisadvantage is every method in the interface must be public. You might not want to expose everything. 

*When To Use Abstract classes An abstract class, in contrast, provides more structure. It usually defines some default implementations andprovides some tools useful for a full implementation. The catch is, code using it must use your class as thebase. That may be highly inconvenient if the other programmers wanting to use your package have alreadydeveloped their own class hierarchy independently. In Java, a class can inherit from only one base class.*When to Use Both You can offer the best of both worlds, an interface and an abstract class. Implementors can ignore yourabstract class if they choose. The only drawback of doing that is calling methods via their interface name isslightly slower than calling them via their abstract class name. 

Reference:http://mindprod.com/jgloss/interfacevsabstract.html 

Q2. Assuming the port statements are correct, which two (three?) code fragments create a one-byte file? 

A. OutputStream fos = new FileOutputStream(new File("/tmp/data.bin")); OutputStream bos = new BufferedOutputStream(fos); DataOutputStream dos = new DataOutputStream(bos); dos.writeByte(0); dos.close(); 

B. OutputStream fos = new FileOutputStream ("/tmp/data.bin"); 

DataOutputStream dos = new DataOutputStream(fos); 

dos.writeByte(0); 

dos.close(); 

C. OutputStream fos = new FileOutputStream (new File ("/tmp/data.bin")); 

DataOutputStream dos = new DataOutputStream(fos); 

dos.writeByte(0); 

dos.close(); 

D. OutputStream fos = new FileOutputStream ("/tmp/data.bin"); fos.writeByte(0); 

fos.close(); 

Answer: A,B,C 

Explanation: 

B:Create DataOutputStream from FileOutputStream public static void main(String[] args) 

throws 

Exception { FileOutputStream fos = new FileOutputS tream("C:/demo.txt"); 

DataOutputStream dos = new 

DataOutputStream(fos); 

Note: 

The FileOutputStream class is a subclass of OutputStream. You can construct a 

FileOutputStream object by 

passing a string containing a path name or a File object. 

You can also specify whether you want to append the output to an existing file. 

public FileOutputStream (String path) 

public FileOutputStream (String path, boolean append) 

public FileOutputStream (File file) 

public FileOutputStream (File file, boolean append) 

With the first and third constructors, if a file by the specified name already exists, the file 

will be overwritten. Toappend to an existing file, pass true to the second or fourth 

constructor. 

Note 2:public class DataOutputStreamextends FilterOutputStreamimplements DataOutput 

A data output stream lets an application write primitive Java data types to an output stream 

in a portable way. 

An application can then use a data input stream to read the data back in. 

Reference:java.io Class DataOutputStream 

Q3. 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 

Answer: A,C 

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. 

Q4. Which represents part of a DAO design pattern? 

A. interface EmployeeDAO { 

int getID(); 

Employee findByID (intid); 

void update(); 

void delete(); 

B. class EmployeeDAO { 

int getID() { return 0;} 

Employee findByID (int id) { return null;} 

void update () {} 

void delete () {} 

C. class EmployeeDAO { 

void create (Employee e) {} 

void update (Employee e) {} 

void delete (int id) {} 

Employee findByID (int id) {return id} 

D. interface EmployeeDAO { 

void create (Employee e); 

void update (Employee e); 

void delete (int id); 

Employee findByID (int id); 

E. interface EmployeeDAO { 

void create (Connection c, Employee e); 

void update (Connection c, Employee e); 

void delete (Connection c, int id); 

Employee findByID (Connection c, int id); 

Answer:

Q5. 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 

Answer:

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. 

Q6. Given: 

What is the result? 

A. Nice to see you,be fine 

B. Nice,see you,be fine 

C. Nice,see you, to, be fine 

D. Nice, see you, be fine 

E. Nice to see y, u, be fine 

Answer:

Explanation: 

The text ",to," is replaced by the "," 

Q7. Given: 

What is the result? 

A. Event Quiz 

B. Event Event 

C. Quiz Quiz 

D. Quiz Event 

E. Compilation fails 

Answer:

Q8. To provide meaningful output for: 

System.out.print( new Item ()): 

A method with which signature should be added to the Item class? 

A. public String asString() 

B. public Object asString() 

C. public Item asString() 

D. public String toString() 

E. public object toString() 

F. public Item toString() 

Answer:

Explanation: 

Implementing toString method in java is done by overriding the Object's toString method. 

The javatoString() method is used when we need a string representation of an object. It is 

defined in Object class. Thismethod can be overridden to customize the String 

representation of the Object. 

Note: 

Below is an example shown of Overriding the default Object toString() method. The 

toString() method must bedescriptive and should generally cover all the contents of the 

object. 

class PointCoordinates { 

private int x, y; 

public PointCoordinates(int x, int y) { 

this.x = x; 

this.y = y; 

public int getX() { 

return x; 

public int getY() { 

return y; 

// Custom toString() Method. 

public String toString() { 

return "X=" + x + " " + "Y=" + y; 

}} 

Q9. Which two codes correctly represent a standard language locale code? 

A. ES 

B. FR 

C. U8 

D. Es 

E. fr 

F. u8 

Answer: A,B 

Explanation: 

Language codes are defined by ISO 639, an international standard that assigns two- and three-letter codes tomost languages of the world. Locale uses the two-letter codes to identify the target language. 

Q10. Which four are true about enums? 

A. An enum is typesafe. 

B. An enum cannot have public methods or fields. 

C. An enum can declare a private constructor. 

D. All enums implicitly implement Comparable. 

E. An enum can subclass another enum. 

F. An enum can implement an interface. 

Answer: A,C,D,F Explanation: 

C: The constructor for an enum type must be package-private or private access. Reference: Java Tutorials,Enum Types