It is impossible to pass Oracle 1Z0-804 exam without any help in the short term. Come to Examcollection soon and find the most advanced, correct and guaranteed Oracle 1Z0-804 practice questions. You will get a surprising result by our Renovate Java SE 7 Programmer II Exam practice guides.

2021 Jul java exam 1z0-804:

Q51. Given: 

What two changes, made independently, will enable the code to compile? 

A. Change the signature of Account to: public class Account. 

B. Change the signature of CheckingAccount to: public abstract CheckingAccount 

C. Implement private methods for deposit and withdraw in CheckingAccount. 

D. Implement public methods for deposit and withdraw in CheckingAccount. 

E. Change Signature of checkingAccount to: CheckingAccount implements Account. 

F. Make Account an interface. 

Answer: B,D 

Explanation: 

Compiler say: 

-

Der Typ CheckingAccount muss die übernommene abstrakte Methode Account.deposit(double) implementieren 

-

Der Typ CheckingAccount muss die übernommene abstrakte Methode Account.withdraw(double) implementieren ODER Typ CheckingAccount als abstract definieren 


Q52. 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: D 


Q53. Which three statements are correct about thread's sleep method? 

A. The sleep (long) method parameter defines a delay in milliseconds. 

B. The sloop (long) method parameter defines a delay in microseconds. 

C. A thread is guaranteed to continue execution after the exact amount of time defined in the sleep (long)parameter. 

D. A thread can continue execution before the amount of time defined in the sleep (long) parameter. 

E. A thread can continue execution after the amount of time defined in the sleep (long) parameter 

F. Only runtime exceptions are thrown by the sleep method. 

G. A thread loses all object monitors (lock flags) when calling the sleep method. 

Answer: A,C,E 

Explanation: 

sleep (long millis) not B Causes the currently executing thread to sleep (temporarily cease execution) for the specified number ofmilliseconds(A, not B) millis - the length of time to sleep in milliseconds. throws InterruptedException: - if another thread has interrupted the current thread. The interrupted status ofthe current thread is cleared when this exception is thrown. java.lang.Throwable java.lang.Exception java.lang.InterruptedException The thread does not lose ownership of any monitors. It means that if the thread has an object-monitor, all otherthreads that need that monitor are blocked. This method can be called regardless whether the thread has any monitor or not. 


Q54. Given: 

What is the result? 

A. fast slow 

B. fast goes 

C. goes goes 

D. fast fast 

E. fast followed by an exception 

F. Compilation fails 

Answer: F 

Explanation: 

Line:Vehicle v = new Sportscar(); 

causes compilation failure: 

error: cannot find symbol 

Vehicle v = new Sportscar(); 

symbol: class Sportscar 

location: class VehicleTest 


Q55. Given: 

Which statement, inserted at line 8, enables the code to compile? 

A. new Task().new Counter().increment(); 

B. new Task().Counter().increment(); 

C. new Task.Counter().increment(); 

D. Task.Counter().increment(); 

E. Task.Counter.increment(); 

Answer: C 


1Z0-804  sample question

Down to date exams 1z0-803 & 1z0-804:

Q56. Given: Which three statements concerning the OO concepts "is-a" and "has-a" are true? 

A. Flimmer is-a Plinkable 

B. Flommer has-a Tagget 

C. Flommer is-a Glommer 

D. Tagget has-a String 

E. Flommer is-a Plinkable 

F. Flimmer is-a Flommer 

G. Tagget is-a Plinkable 

Answer: A,B,E 

Explanation: 

A: Flimmer implements Plinkable. 

Flimmer is-a plinkable. 

D:The relationship modeled by composition is often referred to as the "has-a" relationship. 

HereTaggethasaString. 

F: Flommer extends Flimmer 

So there is an "is-a relationship between Flommer and Flimmer . 

Note: Thehas-a relationship has anencapsulation feature (like private or protected modifier 

used before eachmember field or method). 


Q57. Given: 

Which fragment, inserted in the Books interface, enables the code to compile? 

A. public abstract String type; public abstract String getType(); 

B. public static String type; public abstract String getType(); 

C. public String type = "Fiction"; public static String getType(); 

D. public String type = "Fiction"; public abstract String getType(); 

Answer: D 


Q58. 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: B 

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 


Q59. Given: 

And the commands: javac Counter.java java ea Counter 

What is the result? 

A. 2 

B. 3 

C. NullPointException is thrown at runtime 

D. AssertionError is thrown at runtime 

E. Compilation fails 

Answer: B 

Explanation: 

The command line javac Counter.java 

Willcompile the code. 

The command line java ea Counter 

Willrun the cod with assertions enabled. 

Assertion is true because getCount(arr) = 3 and Length of array is 4 

The following line: 

assert (getCount(arr) < arr.length); 

where the Boolean expression getCount(arr) < arr.length will evaluate to false, will ensure 

that anAssertionError is thrown at runtime. 

Note:The javac command compiles Java source code into Java bytecodes. You then use 

the Java interpreter -the java command - to interprete the Java bytecodes. 

Note 2:The java tool launches a Java application. It does this by starting a Java runtime 

environment, loading aspecified class, and invoking that class's main method. The method 

declaration must look like the following:public static void main(String args[]) 

Paramater ea: 

-enableassertions[:<package name>"..." | :<class name> ] -ea[:<package name>"..." | 

:<class name> ] 

Enable assertions. Assertions are disabled by default. With no arguments, 

enableassertions or -ea enablesassertions. 

Note 3: 

An assertion is a statement in the JavaTM programming language that enables you to test 

your assumptionsabout your program. 

Each assertion contains a boolean expression that you believe will be true when the 

assertion executes. If it isnot true, the system will throw an error. 


Q60. Given: 

Which group of method is moved to a new class when implementing the DAO pattern? 

A. public in getId () 

public String getContractDetails () 

public Void setContractDetails(String contactDetails) 

public String getName () 

public void setName (String name) 

B. public int getId () 

public String getContractDetails() 

public String getName() 

public Person getPerson(int id) throws Exception 

C. public void setContractDetails(String contractDetails) 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 

Answer: D 

Explanation: 

The methods related directly to the entity Person is moved to a new class. 

CRUD 

Note:DAO Design Pattern 

*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) 

D:Documents and SettingsuseralboDesktop1.jpg 

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