Want to know Testking 1Z0-804 Exam practice test features? Want to lear more about Oracle Java SE 7 Programmer II Exam certification experience? Study Accurate Oracle 1Z0-804 answers to Renovate 1Z0-804 questions at Testking. Gat a success with an absolute guarantee to pass Oracle 1Z0-804 (Java SE 7 Programmer II Exam) test on your first attempt.

2021 Jul 1z0-804 study guide:

Q91. For which three objects must a vendor provide implementations in its JDBC driver? 

A. Time 

B. Date 

C. Statement 

D. ResultSet 

E. Connection 

F. SQLException 

G. DriverManager 

Answer: C,D,E 


All JDBC drivers implement the four important JDBC classes: Driver, Connection, Statement, and ResultSet. 

Q92. Given these facts about Java classes in an application: 


Class X is-a Class SuperX. 


Class SuperX has-a public reference to a Class Z. 


Class Y invokes public methods in Class Util. 


Class X uses public variables in Class Util. 

Which three statements are true? 

A. Class X has-a Class Z. 

B. Class Util has weak encapsulation. 

C. Class Y demonstrates high cohesion. 

D. Class X is loosely coupled to Class Util. 

E. Class SuperX's level of cohesion CANNOT be determined 

Answer: B,D,E 


B: Has class Util has both public methods and variables, it is an example of weak 


Note:Inheritance is also sometimes said to provide "weak encapsulation," because if you 

have code thatdirectly uses a subclass, such as Apple, that code can be broken by 

changes to a superclass, such as Fruit. 

One of the ways to look at inheritance is that it allows subclass code to reuse superclass 

code. For example, if 

Apple doesn't override a method defined in its superclass 

Fruit, Apple is in a sense reusing Fruit's implementation of the method. But Apple only 

"weakly encapsulates"the Fruit code it is reusing, because changes to Fruit's interface can 

break code that directly uses Apple. 


Note:Tight coupling is when a group of classes are highly dependent on one another. 

This scenario arises when a class assumes too many responsibilities, or when one concern 

is spread overmany classes rather than having its own class. 

Loose coupling is achieved by means of a design that promotes single-responsibility and 

separation ofconcerns. 

A loosely-coupled class can be consumed and tested independently of other (concrete) 


Interfaces are a powerful tool to use for decoupling. Classes can communicate through 

interfaces rather thanother concrete classes, and any class can be on the other end of that 

communication simply by implementingthe interface. 

E: Not enough information regarding SuperX' to determine the level of cohesion. 

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


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. 

Q94. 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: A 


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

Q95. Given the fragment: 

Which two valid alternatives to line 3 would decouple this application from a specific implementation ofCustomerDAO? 

A. CustomerDAO custDao = CustomerDAO(); 

B. CustomerDAO custDao = (CustomerDAO) new Object (); 

C. CustomerDAO custDao = CustomerDAO.getInstance(); 

D. CustomerDAO custDao = (CustomerDAO) new CustomerDAOmemoryImp1(); 

E. CustomerDAO custDao = customerDAOFactory.getInstance(); 

Answer: C,E 


Note: In software development, the term"decoupling"is used to identify the separation of software blocks thatshouldn't depend on each other. Some building blocks are generic and shouldn't know details of others. Special design techniques allow software designers to have as few dependencies as possible. This typicallyreduces the risk of malfunction in one part of a system when the other part changed. It also forces thedeveloper to focus on one thing at a time. Decoupling lowers or minimizes Coupling. 


Rebirth 1z0-804 sample questions:

Q96. Given these facts about Java types in an application: 


Type x is a template for other types in the application. 


Type x implements dostuff (). 


Type x declares, but does NOT implement doit(). 


Type y declares doOther() . 

Which three are true? 

A. Type y must be an interface. 

B. Type x must be an abstract class. 

C. Type y must be an abstract class. 

D. Type x could implement or extend from Type y. 

E. Type x could be an abstract class or an interface. 

F. Type y could be an abstract class or an interface. 

Answer: B,D,F 


Unlike interfaces, abstract classes can contain fields that are not static and final, and they can containimplemented methods. Such abstract classes are similar to interfaces, except that they provide a partialimplementation, leaving it to subclasses to complete the implementation. If an abstract class contains onlyabstract method declarations, it should be declared as an interface instead. 

Note: An interface in the Java programming language is an abstract type that is used to specify an interface (in thegeneric sense of the term) that classes must implement. Interfaces are declaredusing the interface keyword,and may only contain method signature and constant declarations (variable declarations that are declared tobe both static and final). An interface maynever contain method definitions. 

Note 2: an abstract class is a class that is declared abstract--it may or may not include abstract methods.Abstract classes cannot be instantiated, but they can be subclassed. An abstract method is a method that isdeclared without an implementation (without braces, and followed by a semicolon) 

Q97. Given: Which of the four are valid modifications to synchronize access to the valid list between threads t1 and t2? 

A. Replace line 1 with: 

Synchronized (t2) (t1.start();) synchronized(t1) (t2.start(); ) 

korrekte Schreibweise: synchronized (t2) {t1.start();} synchronized(t1) { t2.start();} 

B. Replace Line 2 with: 

static CopyWriteArrayList<Integer> list = new CopyWriteArrayList<>(); 

korrekte Schreibweise: static CopyOnWriteArrayList<Integer> list = new 


C. Replace line 3 with: 

synchronized public static void addItem () { 

korrekte Schreibweise: synchronized public static void addItem () { 

D. Replace line 4 with: 

synchronized (list) (list.add(1);) 

korrekte Schreibweise: synchronized (list) { (list.add(1); } 

E. Replace line 5 with: 

Synchronized public void run () { 

korrekte Schreibweise: synchronized public void run () { 

F. replace line 6 with: 

Synchronized (this) {for (in i = 0, i<5000, i++) WorkPool.addItem(); } 

korrekte Schreibweise: synchronized (this) {for (int i = 0; i<500; i++) WorkPool.addItem(); } 

G. Replace line 6 with: 

synchronized (bar) {for (int i= 0; i<5000; i++) WorkPool.addItem(); } 

korrekte Schreibweise: synchronized (bar) {for (int i= 0; i<500; i++) WorkPool.addItem(); } 

Answer: B,C,D 


Away to create synchronized code is with synchronized statements. 

Unlike synchronized methods, synchronized statements must specify the object that 

provides theintrinsic lock: 

For example: 

public void addName(String name) { 

synchronized(this) { 

lastName = name; 



In this example, the addName method needs to synchronize changes to lastName and 

nameCount, but alsoneeds to avoid synchronizing invocations of other objects' methods. 

Without synchronized statements, therewould have to be a separate, unsynchronized 

method for the sole purpose of invoking nameList.add. 

Reference: The Java Tutorial,Intrinsic Locks and Synchronization 

Q98. Which is a key aspect of composition? 

A. Using inheritance 

B. Method delegation 

C. Creating abstract classes 

D. Implementing the composite interface 

Answer: B 


In the composition approach, the subclass becomes the "front-end class," and the superclass becomes the"back-end class." With inheritance, a subclass automatically inherits an implemenation of any non-privatesuperclass method that it doesn't override. With composition, by contrast, the front-end class must explicitlyinvoke a corresponding method in the back-end class from its own implementation of the method. This explicitcall is sometimes called "forwarding" or "delegating" the method invocation to the back-end object.Note: Composition means the same as: 


is part of Note 2: As you progress in an object-oriented design, you will likely encounter objects in the problem domainthat contain other objects. In this situation you will be drawn to modeling a similar arrangement in the design ofyour solution. In an object-oriented design of a Java program, the way in which you model objects that containother objects is with composition, the act of composing a class out of references to other objects. Withcomposition, references to the constituent objects become fields of the containing object. To use compositionin Java, you use instance variables of one object to hold references to other objects. 

Q99. Given the code fragment: 

Why is there no output when otherMethod is called? 

A. An exception other than IOException is thrown. 

B. Standard error is not mapped to the console. 

C. There is a compilation error. 

D. The exception is suppressed. 

Answer: C 


C: wenn printStackTrace() ohne Referenz auf das Exception object aufgerufen 

A : java.io.FileNotFoundException: wenn e.printStackTrace(); 

The code compiles fine 

The line 

FileInputStream fis = new FileInputStream(file)) 

will fail at runtime since file is an empty string. 


public void printStackTrace() 

Prints this throwable and its backtrace to the standard error stream. 

Q100. Given: 

Which three are true? 

A. BasicCar uses composition. 

B. SuperCar uses composition. 

C. BasicCar is-a Car. 

D. SuperCar is-a Car. 

E. SuperCar takes advantage of polymorphism 

F. BasicCar has-a Car 

Answer: B,C,E 


B: The relationship modeled by composition is often referred to as the "has-a" relationship. Here SuperCarhas-a Car. 

C:The relationship modeled by inheritance is often referred to as the "is-a" relationship. Modeling an is-arelationship is called inheritance because the subclass inherits the interface and, by default, theimplementation of the superclass. Inheritance of interface guarantees that a subclass can accept all the samemessages as its superclass. A subclass object can, in fact, be used anywhere a superclass object is called for.E:The polymorphic method call allows one type to express its distinction from another, similar type, as long asthey're both derived from the same base type. This distinction is expressed through differences in behavior ofthe methods that you can call through the base class.