Weekend Sale Special Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: suredis

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

Page: 1 / 22
Total 224 questions

Java SE 8 Programmer I Questions and Answers

Testing Engine

  • Product Type: Testing Engine
$42  $119.99

PDF Study Guide

  • Product Type: PDF Study Guide
$36.75  $104.99
Question 1

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 2

Given this array:

Which two code fragments, independently, print each element in this array? (Choose two.)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

F.

Option F

Question 3

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 4

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 5

Given:

What is the result?

Options:

A.

100 200 : 0 0 :

B.

100 200 : 100 0 :

C.

100 200 : 100 200 :

D.

0 0 : 100 0 :

Question 6

Given:

What is the result?

Options:

A.

3 4 5 6

B.

3 4 3 6

C.

5 4 5 6

D.

3 6 4 6

Question 7

Given:

What is the result?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 8

Given the code fragment:

Which three code fragments can be independently inserted at line n1 to enable the code to print One? (Choose three.)

Options:

A.

byte x = 1;

B.

short x = 1;

C.

String x = "1";

D.

long x = 1;

E.

double x = 1;

F.

Integer x = new Integer("1");

Question 9

Given the code fragment:

Which three code fragments are valid at line n1?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 10

Given the code fragments:

And:

Which statement is true?

Options:

A.

After line 11, three objects are eligible for garbage collection.

B.

After line 11, two objects are eligible for garbage collection.

C.

After line 11, one object is eligible for garbage collection.

D.

After line 11, none of the objects are eligible for garbage collection.

Question 11

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 12

Given the code fragment:

And given the requirements:

1. Process all the elements of the array in the order of entry.

2. Process all the elements of the array in the reverse order of entry.

3. Process alternating elements of the array in the order of entry.

Which two statements are true? (Choose two.)

Options:

A.

Requirements 1, 2, and 3 can be implemented by using the enhanced for loop.

B.

Requirements 1, 2, and 3 can be implemented by using the standard for loop.

C.

Requirements 2 and 3 CANNOT be implemented by using the standard for loop.

D.

Requirement 1 can be implemented by using the enhanced for loop.

E.

Requirement 3 CANNOT be implemented by using either the enhanced for loop or the standard for loop.

Question 13

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 14

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

Question 15

Given the code fragment:

What is the result?

Options:

A.

1324

B.

2313

C.

3142

D.

4231

Question 16

Which two array initialization statements are valid? (Choose two.)

Options:

A.

int array[] = new int[3] {1, 2, 3};

B.

int array[] = new int[3]; array[0] = 1;

array[1] = 2;

array[2] = 3;

C.

int array[3] = new int[] {1, 2, 3};

D.

int array[] = new int[3]; array = {1, 2, 3};

E.

int array[] = new int[] {1,2,3};

Question 17

Which two initialization statements are valid? (Choose two.)

Options:

A.

Boolean available = “TRUE”:

B.

String tmpAuthor = author, author =”Mc Donald”;

C.

Double price = 200D;

D.

Integer pages = 20;

Question 18

Given the following main method:

What is the result?

Options:

A.

5 4 3 2 1 0

B.

5 4 3 2 1

C.

4 2 1

D.

5

E.

Nothing is printed

Question 19

Which three statements describe the object-oriented features of the Java language? (Choose three.)

Options:

A.

Objects cannot be reused.

B.

A subclass must override the methods from a superclass.

C.

Objects can share behaviors with other objects.

D.

A package must contain a main class.

E.

Object is the root class of all other objects.

F.

A main method must be declared in every class.

Question 20

Given:

What is the result?

Options:

A.

10

20

B.

A compile time error occurs

C.

20

20

D.

10

10

Question 21

Given the code fragment:

Which three lines fail to compile? (Choose three.)

Options:

A.

Line 7

B.

Line 8

C.

Line 9

D.

Line 10

E.

Line 11

F.

Line 12

Question 22

Given the code fragment:

Which modification enables the code to print 54321?

Options:

A.

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

B.

At line 7, insert x --;

C.

Replace line 5 with while (is Available(--x)) {

D.

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

Question 23

Given:

And the code fragment:

Which code fragment, when inserted at line 14, enables the code to print Mike Found?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 24

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 25

Given:

Which statement is true?

Options:

A.

The program executes and prints:

500.0

B.

Commenting line 16 enables the program to print:

Thank You! 500.0

C.

Commenting line 13 enables the program to print:

Thank You! 500.0

D.

The program executes and prints:

Thank You! 500.0

Question 26

Given the code fragment:

Which code fragment, when inserted at line n1, enables the App class to print Equal?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 27

Which three statements describe the object-oriented features of the Java language? (Choose three.)

Options:

A.

Objects cannot be reused.

B.

A subclass must override the methods from a superclass.

C.

Objects can share behaviors with other objects.

D.

A package must contain a main class.

E.

Object is the root class of all other objects.

F.

A main method must be declared in every class.

Question 28

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 29

Given:

And given the code fragment:

What is the result?

Options:

A.

Compilation fails at line n2.

B.

Read Book

C.

Read E-Book

D.

Compilation fails at line n1.

E.

Compilation fails at line n3.

Question 30

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 31

Given:

And given the code fragment:

What is the result?

Options:

A.

Compilation fails at line n2.

B.

Compilation fails at line n1.

C.

20:20

D.

10:20

Question 32

Given this code for a Planet object:

What is the output?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 33

Given:

What is the result? A. 0:0

100:0

B.null:0

100:0

C.0:0

100:200

D.null:null 100:null

Options:

Question 34

Given the code fragment:

What is the result?

Options:

A.

S 6

B.

S 5

C.

s-1

D.

w 7

Question 35

Given the code fragment:

Which two modifications, made independently, enable the code to compile? (Choose two.)

Options:

A.

Make the method at line n1 public.

B.

Make the method at line n2 public.

C.

Make the method at line n3 public.

D.

Make the method at line n3 protected.

E.

Make the method at line n4 public.

Question 36

Given the code fragment:

What is the result?

Options:

A.

3

B.

4

C.

-1

D.

Compilation fails.

Question 37

Given:

What is the result?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 38

Given:

What is the result?

Options:

A.

10 : 30 : 6

B.

10 : 22 : 22

C.

10 : 22 : 20

D.

10 : 22 : 6

Question 39

Given:

What is the result?

Options:

A.

c=null

b=true

f=0.0

B.

c=

b=false

f=0.0

C.

c=null

b=false

f=0.0

D.

c=0

b=false

f=0.0F

Question 40

Given:

What is the result?

Options:

A.

Compilation fails.

B.

11

C.

8

D.

9

E.

10

Question 41

Given the code from the Greeting.Java file:

Which set of commands prints Hello Duke in the console?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 42

Given:

Which two code fragments can be inserted at line n1?

Options:

A.

String str = “Java”;

B.

for(int iVal = 0; iVal <=5; iVal++){}

C.

Test() {}

D.

package p1;

E.

import java.io.*;

Question 43

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 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 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 46

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 47

Given:

Which code fragment can replace the if block?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 48

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

C.

Its case label literals can be changed at runtime.

D.

Its expression must evaluate to a collection of values.

Question 49

Given:

What is the result?

Options:

A.

Compilation fails at line n1.

B.

InitializedStartedInitialized

C.

InitializedStarted

D.

Compilation fails at line n2.

Question 50

Which two statements are true about Java byte code? (Choose two.)

Options:

A.

It can be serialized across network.

B.

It can run on any platform that has a Java compiler.

C.

It can run on any platform.

D.

It has “.java” extension.

E.

It can run on any platform that has the Java Runtime Environment.

Question 51

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 52

Given the code fragment:

Which code fragment, when inserted at line 9, enables the code to print true?

Options:

A.

String str2 = str1;

B.

String str2 = new String(str1);

C.

String str2 = sb1. toString();

D.

String str2 = "Duke";

Question 53

Which three statements are true about the structure of a Java class? (Choose three.)

Options:

A.

A public class must have a main method.

B.

A class can have only one private constructors.

C.

A method can have the same name as a field.

D.

A class can have overloaded static methods.

E.

The methods are mandatory components of a class.

F.

The fields need not be initialized before use.

Question 54

Given:

What is the result?

Options:

A.

200.0 : 100.0

B.

400.0 : 200.0

C.

400.0 : 100.0

D.

Compilation fails.

Question 55

Given:

And given the commands:

What is the result?

Options:

A.

Java SE

B.

Java EE

C.

Compilation fails at line n1.

D.

A NullPointerException is thrown at runtime.

Question 56

Given:

What is the result?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 57

Given the code fragment:

What is the result?

Options:

A.

An exception is thrown at runtime.

B.

07-31-2014

C.

2014-07-31

D.

2014-09-30

Question 58

Given the code fragment:

What is the result?

Options:

A.

A B C Work done

B.

A B C D Work done

C.

A Work done

D.

Compilation fails

Question 59

Given the code fragment:

What is the result?

Options:

A.

May 04, 2014T00:00:00.000

B.

2014-05-04T00:00: 00.000

C.

5/4/14T00:00:00.000

D.

An exception is thrown at runtime.

Question 60

Given:

What is the result?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 61

Given the code fragment:

What is the result?

Options:

A.

100

B.

101

C.

102

D.

103

E.

Compilation fails

Question 62

Given:

What is the result?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 63

Given:

And given the commands:

What is the result?

Options:

A.

Success

B.

Failure

C.

Compilation fails.

D.

An exception is thrown at runtime

Question 64

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 65

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 66

Given the definitions of the MyString class and the Test class:

What is the result?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 67

Given the code fragment:

What is the result?

Options:

A.

A B C Work done

B.

A B C D Work done

C.

A Work done

D.

Compilation fails

Page: 1 / 22
Total 224 questions