1Z0-804 | What Highest Quality 1Z0-804 exam Is?


Q1. Given the code fragment: SimpleDataFormat sdf; 

Which code fragment displays the three-character month abbreviation? 

A. SimpleDateFormat sdf = new SimpleDateFormat ("mm", Locale.UK); System.out.println 

("Result:" + 

sdf.format(new Date())); 

B. SimpleDateFormat sdf = new SimpleDateFormat ("MM", Locale.UK); System.out.println 

("Result:" + 

sdf.format(new Date())); 

C. SimpleDateFormat sdf = new SimpleDateFormat ("MMM", Locale.UK); 

System.out.println ("Result:" + 

sdf.format(new Date())); 

D. SimpleDateFormat sdf = new SimpleDateFormat ("MMMM", Locale.UK); 

System.out.println ("Result:" + 

sdf.format(new Date())); 

Answer:

Q2. Given: What is the result? 

A. false false 

B. true false 

C. true true 

D. Compilation fails 

E. An exception is thrown at runtime 

Answer:

Explanation: 

(this == obj) is the object implementation of equals() and therefore FALSE, if the reference 

points to variousobjectsand then the super.equals() is invoked, the object method equals() 

what still result in FALSEbetter override of equals() is to compare the attributes like: 

public boolean equals (Object obj) { 

if (obj != null){ 

Product p = (Product)obj; 

return this.id == p.id; 

return false; 

Q3. Which code fragment correctly appends "Java 7" to the end of the file /tmp/msg.txt? 

A. FileWriter w = new FileWriter("/tmp/msg.txt"); 

append("Java 7"); 

close(); 

B. FileWriter w = new FileWriter("/tmp/msg.txt", true); 

append("Java 7"); 

close(); 

C. FileWriter w = new FileWriter("/tmp/msg.txt", FileWriter.MODE_APPEND); 

append("Java 7"); 

close(); 

D. FileWriter w = new FileWriter("/tmp/msg.txt", Writer.MODE_APPEND); 

append("Java 7"); 

close(); 

Answer:

Explanation: 

FileWriter(File file, boolean append) 

A: clears the file and append "Java7" 

Constructs a FileWriter object given a File object. 

If the second argument is true, then bytes will be written to the end of the file rather than 

the beginning.Parameters: 

file - a File object to write toappend - if true, then bytes will be written to the end of the file 

rather than the beginning 

Q4. ITEM Table 

ID, INTEGER: PK 

DESCRIP, VARCHAR(100) 

PRICE, REAL 

QUALITY, INTEGER 

And given the code fragment (assuming that the SQL query is valid): 

What is the result of compiling and executing this code? 

A. An exception is thrown at runtime 

B. Compile fails 

C. The code prints Error 

D. The code prints information about Item 110 

Answer:

Explanation: 

Tricky: 

Compiles successfully ! Not B ! 

D is correct, if Column Quantity instead of Quality 

Table Item Column Quality --- System.out.println("Quantity: " + rs.getInt("Quantity")); 

wenn jedoch so gewollt: die Zeile gibt Error aus (die anderen funktionieren) !!! 

The connection conn is not defined. The code will not compile. 

Q5. Give: 

What is the result? 

A. There are 27 sports cars and 5 trucks 

B. There are 27 convertibles and 5 trucks 

C. There are 9 sports cars and 5 trucks 

D. There are 9 convertibles and 5 trucks 

E. IllegalFormatConversionException is thrown at runtime 

Answer:

Explanation: 

Strings are immutable, therefore no change at line: svar.replace(svar,"convertibles"); 

Format String Syntax: 

%[argument_index$][flags][width][.precision]conversion 

The optional argument_index is a decimal integer indicating the position of the argument in 

the argument list. 

The first argument is referenced by "1$", the second by "2$", etc. 

The optional flags is a set of characters that modify the output format. The set of valid flags 

depends on theconversion. 

's', 'S' general 

'd' integral The result is formatted as a decimal / integer 

Q6. Given the class? 

What is the result? 

A. Jane Doe John Doe Joe Shmoe 

B. John Doe Jane Doe Joe Shmoe 

C. Joe Shmoe John Doe Jane Doe 

D. Joe Shmoe Jane Doe John Doe 

E. Jane Doe Joe Shmoe John Doe 

F. John Doe Joe Shmoe Jane Doe 

Answer:

Explanation: The list will be sorted alphabetically (Lastname / Firstname). first sorted by Lastname if Lastname equals, sorted by firstname Output will be: Jane Doe John Doe Joe Shmoe 

Q7. Given the cache class: 

A. 101 

B. Compilation fails at line 1. 

C. Compilation fails at line 2. 

D. Compilation fails at line 3. 

Answer:

Explanation: 

Compilation failure at line:1 Incorrect number of arguments for type Cache<T>; it cannot be parameterized with arguments <>illegal start of typetype cache.Cache does not take parameters. 

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

Q9. Given: What is the result? 

A. tolting cantering tolting 

B. cantering cantering cantering 

C. compilation fails 

D. an exception is thrown at runtime 

Answer:

Explanation: 

Compiler says: Cannot reduce the visibility of the inherited method from Rideable. müssen 

PUBLIC sein 

public String ride() { return "cantering "; } 

public String ride() { return "tolting "; } 

if this is given then the result would be: 

A : tolting cantering tolting 

Q10. Given: 

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. 

Answer: C,D 

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; } 

102 

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) 

D:Documents and SettingsuseralboDesktop1.jpg