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

Ensurepass

QUESTION 71

Which is a key aspect of composition?

 

A.

Using inheritance

B.

Method delegation

C.

Creating abstract classes

D.

Implementing the composite interface

 

Correct Answer: B

Explanation:

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:

* contains

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

 

 

QUESTION 72

Which four are syntactically correct?

 

A.

package abc;

package def;

import Java.util . * ;

public class Test { }

B.

package abc;

import Java.util.*;

import Java.util.regex.* ;

public class Test { }

C.

package abc;

public class Test {}

import Java.util.* ;

D.

import Java.util.*;

package abc;

public class Test {}

E.

package abc;

import java.util. *;

public class Test{}

F.

public class Test{}

package abc;

import java.util.*{}

G.

import java.util.*;

public class Test{}

H.

package abc;

public class test {}

 

Correct Answer: BEGH

 

 

QUESTION 73

Given:

 

clip_image002

 

What is the result?

 

A.

John Adams

George Washington

Thomas Jefferson

B.

George Washington

John Adams

Thomas Jefferson

C.

Thomas Jefferson

John Adams

George Washington

D.

An exception is thrown at runtime

E.

Compilation fails

 

Correct Answer: B

Explanation:

The program compiles and runs fine.

At runtime the NameList is built and then sorted by natural Order (String >> alphabetically).

QUESTION 74

Given:

 

image missing

 

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

 

Correct 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

 

 

QUESTION 75

Given the code fragment:

 

clip_image004

 

Which three are true?

 

A.

On line 3, the current thread stops and waits until the t1 thread finishes.

B.

On line 3, the t1 thread stops and waits until the current thread finishes.

C.

On line 4, the t1 thread is dead.

D.

On line 4, the t1 thread is waiting to run.

E.

This code cannot throw a checked exception.

F.

This code may throw a checked exception.

 

Correct Answer: ACF

Explanation:

Thejoin()methods waits for this thread to die.

 

 

 

 

 

 

QUESTION 76

Given:

 

clip_image006

 

Which two statements concerning the OO concepts “IS-A” and “HAS-A” are true?

 

A.

Flimmer is-a Glommer.

B.

Flommer has-a String.

C.

Tagget has-a Glommer.

D.

Flimmer is-a ArrayList.

E.

Tagget has-a doStuff()

F.

Tagget is-a Glommer.

 

Correct Answer: BF

Explanation:

B: The relationship modeled by composition is often referred to as the “has-a” relationship.

Here Flommer hasaString.

E: The has-a relationship has an encapsulation feature (like private or protected modifier used before eachmember field or method).

Here Tagget has-a method doStuff()

F: Tagget implements Glommer.

Tagget is-a Glommer.

Note: The has-a relationship has an encapsulation feature (like private or protected modifier used before eachmember field or method).

 

 

 

 

 

 

 

 

 

QUESTION 77

Given:

 

clip_image008

 

What is the result?

 

A.

John-.-George-.-Paul-.-Ringo

B.

John

George

Paul

Ringo

C.

John –

George –

Paul –

Ringo –

D.

An exception is thrown at runtime

E.

Compilation fails

 

Correct Answer: B

Explanation:

The split() method is used to split a string into an array of substrings, and returns the new array.

regex: – followed by two characters

 

 

QUESTION 78

Given these facts about Java classes in an application:

 

clip_image010Class X is-a Class SuperX.

clip_image010[1]Class SuperX has-a public reference to a Class Z.

clip_image010[2]Class Y invokes public methods in Class Util.

clip_image010[3]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.< /font>

D.

Class X is loosely coupled to Class Util.

E.

Class SuperX’s level of cohesion CANNOT be determined

 

Correct Answer: BDE

Explanation:

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

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.

 

D:

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) classes.

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.

 

 

QUESTION 79

Given:

 

StringBuffer b = new StringBuffer(“3”);

 

System.out.print(5+4+b+2+1);

 

What is the result?

 

A.

54321

B.

9321

C.

5433

D.

933

E.

Output is Similar to: 9java.lang.StringBuffer@100490121.

F.

Compilation fails.

 

Correct Answer: F

Explanation:

The code will not compile.

The print function cannot handle the mixture of integers and strings. Exception in thread “main” java.lang.RuntimeException: Uncompilable source code – Erroneous tree type

 

 

QUESTION 80

Given:

 

clip_image012

 

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

 

Correct Answer: D

 

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.