Weekend Sale Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: 70percent

Oracle 1z0-808 Java SE 8 Programmer I Exam Practice Test

Demo: 67 questions
Total 224 questions

Java SE 8 Programmer I Questions and Answers

Question 1

Given:

What is the result?

Options:

A.

C B A

B.

C

C.

A B C

D.

Compilation fails at line n1 and line n2

Question 2

You are asked to develop a program for a shopping application, and you are given this information:

  • The application must contain the classes Toy, EduToy, and ConsToy. The Toy class is the superclass of the other two classes.
  • The int calculatePrice (Toy t) method calculates the price of a toy.
  • The void printToy (Toy t) method prints the details of a toy.

Which definition of the Toy class adds a valid layer of abstraction to the class hierarchy?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 3

Given the code fragment:

What is the result?

Options:

A.

[JavaForum, ExpertForum]

B.

[JavaGroup, ExpertGroup]

C.

[JavaForumGroup, ExpertForumGroup]

D.

[JavaGroup, TechGroup ExpertGroup]

Question 4

Examine the content of App.java:

Which is true?

Options:

A.

The App.class file is stored within the p1 folder. The Test.class file is stored within the p2 sub-folder of p1.

B.

The App class is accessible within the Test class without an import statement.

C.

import p1.App; is used to access the App class within the Test class.

D.

It is optional to have the package statement as the first line of class definitions.

Question 5

Given the code fragment:

Assume that the system date is June 20, 2014. What is the result?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 6

Which statement is true about the switch statement?

Options:

A.

It must contain the default section.

B.

The break statement, at the end of each case block, is mandatory.

C.

Its case label literals can be changed at runtime.

D.

Its expression must evaluate to a single value.

Question 7

Given:

What is the result?

Options:

A.

myStr: 7007, myNum: 7007

B.

Error

C.

myStr: 9009, myNum: 7007

D.

myStr: 7007, myNum: 9009

Question 8

Given:

And given the code fragment:

What is the result?

Options:

A.

300:300200:300

B.

300:100200:300

C.

300:00:300

D.

100:300300:200

Question 9

Given:

What is the result?

Options:

A.

String main 1

B.

An exception is thrown at runtime

C.

String main 1 2 3

D.

String main 123

Question 10

Given:

What is the result?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 11

Given the content of three files:

Which statement is true?

Options:

A.

Only the A.Java file compiles successfully.

B.

Only the B.java file compiles successfully.

C.

Only the C.java file compiles successfully.

D.

The A.Java and B.java files compile successfully.

E.

The B.java and C.java files compile successfully.

F.

The A.Java and C.java files compile successfully.

Question 12

Given the code fragment:

What is the result?

Options:

A.

Execution terminates in the first catch statement, and Caught a RuntimeException is printed to the console.

B.

Execution terminates in the second catch statement, and Caught an Exception is printed to the console.

C.

A runtime error is thrown in the thread "main".

D.

Execution completes normally, and Ready to use is printed to the console.

E.

The code fails to compile because a throws keyword is required.

Question 13

Given:

Which code fragment should you use at line n1 to instantiate the dvd object successfully?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 14

Given:

What is the result?

Options:

A.

C B A

B.

C

C.

A B C

D.

Compilation fails at line n1 and line n2

Question 15

Given the code snippet from a compiled Java source file:

and this output:

Which command should you run to obtain this output?

Options:

A.

java MyFile 2

B.

java MyFile 1 2 3 4

C.

java MyFile 1 2 2

D.

java MyFile 2 2

Question 16

Which is true about the switch statement?

Options:

A.

Its expression can evaluate to a collection of values.

B.

The break statement, at the end of each case block, is optional.

C.

Its case label literals can be changed at runtime.

D.

It must contain the default section.

Question 17

Given the code fragment:

What is the result?

Options:

A.

[Robb, Rick, Bran]

B.

[Robb, Rick]

C.

[Robb, Bran, Rick, Bran]

D.

An exception is thrown at runtime.

Question 18

Given the code fragment:

And given the requirements:

If the value of the qty variable is greater than or equal to 90, discount = 0.5

If the value of the qty variable is between 80 and 90, discount = 0.2

Which two code fragments can be independently placed at line n1 to meet the requirements? (Choose two.)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 19

Given the code fragment:

What is the result?

Options:

A.

Compilation fails.

B.

The program compiles, but it prints nothing.

C.

HiHowAreYou removed

D.

An UnsupportedOperationException is thrown at runtime.

Question 20

Given the code fragment:

Which option can replace xxx to enable the code to print 135?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 21

Given:

What is the result?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 22

Given:

What is the result?

Options:

A.

3 4 5 6

B.

3 4 3 6

C.

5 4 5 6

D.

3 6 5 6

Question 23

What is the name of the Java concept that uses access modifiers to protect variables and hide them within a class?

Options:

A.

Encapsulation

B.

Inheritance

C.

Abstraction

D.

Instantiation

E.

Polymorphism

Question 24

Given:

What is the result?

Options:

A.

Compilation fails.

B.

3 5

C.

0 0

D.

9 25

Question 25

Which two features can be implemented in a Java application by encapsulating the entity classes used? (Choose two.)

Options:

A.

data validation

B.

compile time polymorphism

C.

data hiding

D.

data abstraction

E.

data memory optimization

Question 26

Given the code fragment:

What is the result?

Options:

A.

Compilation fails at both line n1 and line n2.

B.

Compilation fails only at line n2.

C.

Compilation fails only at line n1.

D.

Jesse 25Walter 52

Question 27

Given the code fragment:

What is the result?

Options:

A.

EN FR JP

B.

EN FR

C.

CH

D.

EN FR CH

Question 28

Given the code fragment:

Which action enables it to print AB?

Options:

A.

Comment lines 18 to 21.

B.

Comment line 20.

C.

Comment line 19.

D.

Comment line 16.

Question 29

Given:

Given the code fragment:

Which two sets of actions, independently, enable the code fragment to print Fit?

Options:

A.

At line n1 insert: import clothing.Shirt;At line n2 insert: String color = Shirt.getColor();

B.

At line n1 insert: import clothing;At line n2 insert: String color = Shirt.getColor();

C.

At line n1 insert: import static clothing.Shirt.getColor;At line n2 insert: String color = getColor();

D.

At line n1 no changes required.At line n2 insert: String color = Shirt.getColor();

E.

At line n1 insert: import Shirt;At line n2 insert: String color = Shirt.getColor();

Question 30

Given:

Acc.java:

Which statement is true?

Options:

A.

Both p and s are accessible via obj.

B.

Only s is accessible via obj.

C.

Both r and s are accessible via obj.

D.

p, r, and s are accessible via obj.

Question 31

Given:

What is the result?

Options:

A.

Good Luck!

B.

Good Day!

C.

Welcome!

D.

Hello!

Question 32

Given the code fragment:

What is the result?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 33

Given:

What is the result?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 34

Given these classes:

And given this main method:

Which two options compile when placed at line n1 of the main method? (Choose two.)

Options:

A.

director.stockOptions = 1_000;

B.

employee.salary = 50_000;

C.

manager.budget = 1_000_000;

D.

manager.stockOption = 500;

E.

employee.budget = 200_000;

F.

director.salary = 80_000;

Question 35

Given the code fragment:

What is the result?

Options:

A.

A NullPointerException is thrown at runtime.

B.

[1, 2, 4]

C.

[1, 2, 4, null]

D.

[1, 3, 4, null]

E.

[1, 3, 4]

F.

Compilation fails.

Question 36

Given the code fragment:

Which code fragment at line 10 prints Welcome 100?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 37

Given the code fragment:

Which code fragment, when inserted at line 3, enables the code to print 10:20?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 38

Given:

And given the code fragment:

What is the result?

Options:

A.

4W 100 Auto4W 150 Manual

B.

null 0 Auto4W 150 Manual

C.

Compilation fails only at line n1

D.

Compilation fails only at line n2

E.

Compilation fails at both line n1 and line n2

Question 39

Given the code fragment:

What is the result?

Options:

A.

2012-02-10 00:00

B.

2012-01-30

C.

2012-02-10

D.

A DateTimeException is thrown at runtime.

Question 40

Given the code fragment:

Which modification enables the code fragment to print TrueDone?

Options:

A.

Replace line 5 With String opt = "true";Replace line 7 with case "true":

B.

Replace line 5 with boolean opt = l;Replace line 7 with case 1:

C.

At line 9, remove the break statement.

D.

Remove the default section.

Question 41

Given the code fragment:

What is the result?

Options:

A.

Compilation fails.

B.

0 Found

C.

1 Found

D.

3 Found

Question 42

Given:

And given the code fragment:

What is the result?

Options:

A.

C2C2

B.

C1C2

C.

C1C1

D.

Compilation fails

Question 43

Given the code fragment:

What is the result?

Options:

A.

5 : 5

B.

10 : 10

C.

5 : 10

D.

Compilation fails.

Question 44

Given:

What is the result?

Options:

A.

AB

B.

AC

C.

CC

D.

A ClassCastException is thrown only at line n1.

E.

A ClassCastException is thrown only at line n2.

Question 45

Given:

What is the result?

Options:

A.

double sum is 30.0 float sum is 30.0

B.

float sum is 30.0 double sum is 30.0

C.

Integer sum is 30 double sum is 30.0

D.

Integer sum is 30 float sum is 30.0

Question 46

Given:

What is the result?

Options:

A.

97 9899 100 null null null

B.

97 9899 100 101 102 103

C.

Compilation fails.

D.

A NullPointerException is thrown at runtime.

E.

An ArraylndexOutOfBoundsException is thrown at runtime.

Question 47

Given:

What is the result?

Options:

A.

A B C D

B.

A C D

C.

A C D D

D.

A B D

E.

A B D C

Question 48

Given:

What is the result?

Options:

A.

myStr: 9009, myNum: 9009

B.

myStr: 7007, myNum: 7007

C.

myStr: 7007, myNum: 9009

D.

Compilation fails

Question 49

Given:

What is the result?

Options:

A.

Compilation fails.

B.

false true

C.

true false

D.

true true

E.

false false

Question 50

Given:

What is the result?

Options:

A.

int main 1

B.

Object main 1

C.

String main 1

D.

Compilation fails

E.

An exception is thrown at runtime

Question 51

Given the code fragment:

What is the result?

Options:

A.

2012-02-10

B.

2012-01-30

C.

2012-02-10 00:00

D.

A DateTimeException is thrown at runtime.

Question 52

Given:

And given the commands:

What is the result?

Options:

A.

1 null

B.

true false

C.

false false

D.

true true

E.

A ClassCastException is thrown at runtime.

Question 53

Given the code fragment:

You want the code to print:

Sold: 5 items. Stock in Hand: 5 Purchased: 5 items. Stock in Hand: 10?

Which action enables the code to print this?

Options:

A.

Declare the stock variable and the purchase(), sell(), and printStock() methods static.

B.

Declare the stock variable and the printStock() method static.

C.

Declare the stock and qty variables and the printStock() method static.

D.

Declare the stock variable static.

Question 54

Given:

And given the code fragment:

and this output:

Canine 60 Long

Feline 80 Short

Which two modifications enable the code to print this output? (Choose two.)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 55

Given:

What is the result?

Options:

A.

10 Hello Hello 11

B.

10 Hello Hello 121

C.

100 Hello 121

D.

100 Hello Hello 121

E.

10 Hello 11

Question 56

Which two code fragments cause a compilation error? (Choose two.)

Options:

A.

float flt = 100.00F;

B.

float flt = (float) 1_11.00;

C.

Float flt = 100.00;

D.

double y1 = 203.22;float flt = y1;

E.

int y2 = 100;float flt = (float) y2 ;

Question 57

Given the code fragment:

What is the result?

Options:

A.

A B C

B.

A B C D E

C.

A B D E

D.

Compilation fails.

Question 58

Given the code fragment:

What is the result?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 59

Given:

What is the result?

Options:

A.

a, ei, i

B.

a, eo, o

C.

e, ei, i

D.

a, ao, o

Question 60

Given the code fragment:

What is the result?

Options:

A.

3142

B.

2413

C.

1324

D.

4231

Question 61

Given the code fragment:

Which two code fragments can be independently inserted at line n1 to enable the code to print the elements of the array in reverse order? (Choose two.)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 62

Given the code fragment:

Test.java:

Which is the result?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 63

Given the code fragment:

What is the result?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 64

Which two are benefits of polymorphism? (Choose two.)

Options:

A.

Faster code at runtime

B.

More efficient code at runtime

C.

More dynamic code at runtime

D.

More flexible and reusable code

E.

Code that is protected from extension by other classes

Question 65

Examine:

Which statement is true?

Options:

A.

The program prints m1.Accessed.

B.

The program fails compile due to the unhandled E1 exception.

C.

The program prints m2.Accessed.

D.

The program fails to compile due to the unhandled E2 exception.

Question 66

Which statement will empty the contents of a StringBuilder variable named sb?

Options:

A.

sb. deleteAll ();

B.

sb. delete (0, sb. size () );

C.

sb. delete (0, sb. length () );

D.

sb. removeAll ();

Question 67

Which statement is true about the main() method?

Options:

A.

It is invoked by JRE

B.

It is a final method

C.

It returns true if it is executed successfully at run time

D.

It must be defined within a public class

Demo: 67 questions
Total 224 questions