[Free] Download New Updated (October 2016) Oracle 1Z0-808 Real Exam 111-120

Ensurepass

QUESTION 111

Given:

 

clip_image002

 

Which option enables the code to compile?

 

clip_image004

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

 

Correct Answer: CD

 

 

QUESTION 112

Given the code fragment:

 

clip_image006

 

Which modification enables the code to print 54321?

 

A.

Replace line 6 with System, out. print (–x) ;

B.

At line 7, insert x –;

C.

Replace line 6 with –x; and, at line 7, insert system, out. print (x);

D.

Replace line 12 With return (x > 0) ? false: true;

 

Correct Answer: B

 

 

QUESTION 113

Given:

 

clip_image008

What is the result?

 

A.

Initialized

Started

B.

Initialized

Started

Initialized

C.

Compilation fails

D.

An exception is thrown at runtime

 

Correct Answer: B

 

 

QUESTION 114

Given:

 

clip_image010

 

What is the result?

 

A.

10 : 22 : 20

B.

10 : 22 : 22

C.

10 : 22 : 6

D.

10 : 30 : 6

 

Correct Answer: B

 

 

QUESTION 115

Given the fragment:

 

clip_image012

 

What is the result?

 

A.

13480.0

B.

13480.02

C.

Compilation fails

D.

An exception is thrown at runtime

 

Correct Answer: A

 

QUESTION 116

Given:

 

public class Test {

 

public static void main(String[] args) {

 

int day = 1;

 

switch (day) {

 

case “7”: System.out.print(“Uranus”);

 

case “6”: System.out.print(“Saturn”);

 

case “1”: System.out.print(“Mercury”);

 

case “2”: System.out.print(“Venus”);

 

case “3”: System.out.print(“Earth”);

 

case “4”: System.out.print(“Mars”);

 

case “5”: System.out.print(“Jupiter”);

 

}

 

}

 

}

 

Which two modifications, made independently, enable the code to compile and run?

 

A.

Adding a break statement after each print statement

B.

Adding a default section within the switch code-block

C.

Changing the string literals in each case label to integer

D.

Changing the type of the variable day to String

E.

Arranging the case labels in ascending order

 

Correct Answer: AC

Explanation:

The following will work fine:

 

public class Test {

public static void main(String[] args) {

int day = 1;

switch (day) {

case 7: System.out.print(“Uranus”); break;

case 6: System.out.print(“Saturn”); break;

case 1: System.out.print(“Mercury”); break;

case 2: System.out.print(“Venus”); break;

case 3: System.out.print(“Earth”); break;

case 4: System.out.print(“Mars”); break;

case 5: System.out.print(“Jupiter”); break;

}

}

}

 

 

QUESTION 117

Which three statements are true about the structure of a Java class?

 

A.

A class can have only one private constructor.

B.

A method can have the same name as a field.

C.

A class can have overloaded static methods.

D.

A public class must have a main method.

E.

The methods are mandatory components of a class.

F.

The fields need not be initialized before use.

 

Correct Answer: ABC

Explanation:

A: Private constructors prevent a class from being explicitly instantiated by its callers.

If the programmer does not provide a constructor for a class, then the system will always provide a default, public no-argument constructor. To disable this default constructor, simply add a private no-argument constructor to the class. This private constructor may be empty.

B: The follow
ing works fine:

int cake() {

int cake=0;

return (1);

}

 

C: We can overload static method in Java. In terms of method overloading static method are just like normal methods and in order to overload static method you need to provide another static method with same name but different method signature.

 

Incorrect:

Not D: Only a public class in an application need to have a main method.

Not E:

Example:

class A

{

public string something;

public int a;

}

 

Q: What do you call classes without methods?

Most of the time: An anti pattern.

 

Why? Because it faciliates procedural programming with “Operator” classes and data structures. You separate data and behaviour which isn’t exactly good OOP.

 

Often times: A DTO (Data Transfer Object)

 

Read only datastructures meant to exchange data, derived from a business/domain object.

 

Sometimes: Just data structure.

 

Well sometimes, you just gotta have those structures to hold data that is just plain and simple and has no operations on it.

 

Not F: Fields need to be initialtized. If not the code will not compile.

 

Example:

Uncompilable source code – variable x might not have been initialized

 

 

QUESTION 118

Given:

 

class Base {

 

public static void main(String[] args) {

 

System.out.println(“Base ” + args[2]);

 

}

 

}

 

public class Sub extends Base{

 

public static void main(String[] args) {

 

System.out.println(“Overriden ” + args[1]);

 

}

 

}

 

And the commands:

 

javac Sub.java

 

java Sub 10 20 30

 

What is the result?

 

A.

Base 30

B.

Overridden 20

C.

Overridden 20

Base 30

D.

Base 30

Overridden 20

 

Correct Answer: B

 

 

 

 

 

 

 

 

 

 

QUESTION 119

Given the code fragment:

 

clip_image014

 

What is the result?

 

A.

20

B.

25

C.

29

D.

Compilation fails

E.

AnArrayIndexOutOfBoundsException is thrown at runtime

 

Correct Answer: A

 

 

QUESTION 120

Given:

 

clip_image016

 

What is the output?

 

A.

2015-03-27

B.

2015-04-27

C.

2015-02-27

D.

Compilation fails due to error at line 6.

E.

Compilation fails due to error at line 8.

 

Correct Answer: A

Explanation:

To create we have used following method with LocalDate class; public static LocalDate of(intyear, int month, int dayOfMonth) Here we need to remember that month is not zero based so if you pass 1 for month, then month will be January.

Then we have used period object of 1 day and add to date object which makes current date to next day, so final output is 2015-03-27. Hence option A is correct. https://docs.oracle.com/javase/tutorial/datetime/iso/datetime.html

 

Free VCE & PDF File for Oracle 1Z0-808 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 Uncategorized and tagged , . Bookmark the permalink.