Summer Special Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: geek65

1z0-808 Java SE 8 Programmer I Questions and Answers

Questions 4

Given:

What is the result?

Options:

A.

myStr: 7007, myNum: 7007

B.

Error

C.

myStr: 9009, myNum: 7007

D.

myStr: 7007, myNum: 9009

Buy Now
Questions 5

Given the code snippet from a compiled Java source file:

Which command-line arguments should you pass to the program to obtain the following output?

Arg is 2

Options:

A.

java MyFile 1 3 2 2

B.

java MyFile 2 2 2

C.

java MyFile 1 2 2 3 4

D.

java MyFile 0 1 2 3

Buy Now
Questions 6

Given the code fragment:

What is the result?

Options:

A.

An exception is thrown at runtime.

B.

-1

C.

5

D.

10

Buy Now
Questions 7

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

Buy Now
Questions 8

Given:

What is the result?

Options:

A.

200.0 : 100.0

B.

400.0 : 200.0

C.

400.0 : 100.0

D.

Compilation fails.

Buy Now
Questions 9

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

Buy Now
Questions 10

Given:

Which action fixes the compiler error?

Options:

A.

At line 17, add throws AccessViolationException

B.

At line 13, add throws LogFileException

C.

At line 2, replace throws LogFileException with throws AccessViolationException

D.

At line 7, insert throw new LogFileException ();

Buy Now
Questions 11

Given:

What is the result?

Options:

A.

Compilation fails.

B.

11

C.

8

D.

9

E.

10

Buy Now
Questions 12

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

Buy Now
Questions 13

Given the code fragment:

Which two modifications should you make so that the code compiles successfully? (Choose two.)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Buy Now
Questions 14

Given the code fragment:

What is the result?

Options:

A.

11

B.

10

C.

12

D.

A compile time error occurs.

Buy Now
Questions 15

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.

Buy Now
Questions 16

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.

Buy Now
Questions 17

Given:

What is the result?

Options:

A.

Compilation fails.

B.

false true

C.

true false

D.

true true

E.

false false

Buy Now
Questions 18

Which statement best describes encapsulation?

Options:

A.

Encapsulation ensures that classes can be designed so that only certain fields and methods of an object are accessible from other objects.

B.

Encapsulation ensures that classes can be designed so that their methods are inheritable.

C.

Encapsulation ensures that classes can be designed with some fields and methods declared as abstract.

D.

Encapsulation ensures that classes can be designed so that if a method has an argument MyType x, any subclass of MyType can be passed to that method.

Buy Now
Questions 19

Examine the given definitions:

and the code fragment:

Which statement is true about the implementation of Object-Oriented Programming concepts in the given code?

Options:

A.

Polymorphism, abstraction, and encapsulation are implemented.

B.

Only polymorphism and inheritance are implemented.

C.

Polymorphism, inheritance, and abstraction are implemented.

D.

Only inheritance and encapsulation are implemented.

Buy Now
Questions 20

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.

Buy Now
Questions 21

Given the code fragment:

What is the result?

Options:

A.

2 4

B.

0 2 4 6

C.

0 2 4

D.

Compilation fails.

Buy Now
Questions 22

Given the code fragment:

What is the result?

Options:

A.

Compilation fails.

B.

Hi removed

C.

An UnsupportedOperationException is thrown at runtime.

D.

The program compiles, but it prints nothing.

Buy Now
Questions 23

Given:

How many MarkList instances are created in memory at runtime?

Options:

A.

1

B.

2

C.

3

D.

4

Buy Now
Questions 24

Given:

What is the result?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Buy Now
Questions 25

Given:

and the code fragment:

What is the result?

Options:

A.

true:false:true

B.

false:true:true

C.

false:true:false

D.

true:true:false

Buy Now
Questions 26

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.

Buy Now
Questions 27

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.

Buy Now
Questions 28

Given:

What is the result?

Options:

A.

BaseDerivedA

B.

BaseDerivedB

C.

DerivedBDerivedB

D.

DerivedBDerivedA

E.

A ClassCastException is thrown at runtime.

Buy Now
Questions 29

Given:

What is the result?

Options:

A.

10 : 30 : 6

B.

10 : 22 : 22

C.

10 : 22 : 20

D.

10 : 22 : 6

Buy Now
Questions 30

Given the following classes:

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

Options:

A.

employee.salary = 50_000;

B.

director.salary = 80_000;

C.

employee.budget = 200_000;

D.

manager.budget = 1_000_000;

E.

manager.stockOption = 500;

F.

director.stockOptions = 1_000;

Buy Now
Questions 31

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

Options:

A.

A class cannot have the same name as its field.

B.

A public class must have a main method.

C.

A class can have final static methods.

D.

A class can have overloaded private constructors.

E.

Fields need to be initialized before use.

F.

Methods and fields are optional components of a class.

Buy Now
Questions 32

Given the code fragment from three files:

Which code fragment, when inserted at line 2, enables the code to compile?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Buy Now
Questions 33

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

Buy Now
Questions 34

Given:

What is the result?

Options:

A.

nullRichardDonald

B.

RichardDonald

C.

Compilation fails.

D.

An ArrayIndexOutOfBoundsException is thrown at runtime.

E.

A NullPointerException is thrown at runtime.

Buy Now
Questions 35

Given the code fragment:

What is the result?

Options:

A.

Sum is 600

B.

Compilation fails at line n1.

C.

Compilation fails at line n2.

D.

A ClassCastException is thrown at line n1.

E.

A ClassCastException is thrown at line n2.

Buy Now
Questions 36

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

Buy Now
Questions 37

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

Buy Now
Questions 38

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.

Buy Now
Questions 39

Given the code fragment:

Which option represents the state of the num array after successful completion of the outer loop?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Buy Now
Questions 40

This grid shows the state of a 2D array:

The grid is created with this code:

Which line of code, when inserted in place of //line n1, adds an X into the grid so that the grid contains three consecutive Xs?

Options:

A.

grid[2][1] = ‘X’;

B.

grid[3][2] = ‘X’;

C.

grid[3][1] = ‘X’;

D.

grid[2][3] = ‘X’;

Buy Now
Questions 41

Given these two classes:

Any amount of electricity used by a customer (represented by an instance of the Customer class) must contribute to the customer's bill (represented by the member variable bill) through the useElectricity method.

An instance of the Customer class should never be able to tamper with or decrease the value of the member variable bill.

How should you write methods in the ElectricAccount class at line n1 so that the member variable bill is always equal to the value of the member variable kwh multiplied by the member variable rate?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Buy Now
Questions 42

Given the following code for the classes MyException and Test:

What is the result?

Options:

A.

A

B.

B

C.

Either A or B

D.

A B

E.

A compile time error occurs at line n1

Buy Now
Questions 43

Given:

What is the result?

Options:

A.

true

B.

false

C.

-1

D.

0

Buy Now
Questions 44

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

Buy Now
Questions 45

Given:

What is the result?

Options:

A.

Hello Log 1:0

B.

Hello Log 2:1

C.

Welcome Log 2:1

D.

Welcome Log 1:0

Buy Now
Questions 46

Given the code fragment:

and the requirements of the application:

  • It must display the menu.
  • It must print the option selected.
  • It must continue its execution till it reads ‘0’.

Which code fragment can be used to meet the requirements?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

OptionD

Buy Now
Questions 47

Given:

What is the result?

Options:

A.

400 200

B.

200 200

C.

400 400

D.

Compilation fails.

Buy Now
Questions 48

Given the code fragment:

What is the result?

Options:

A.

Compilation fails.

B.

0 Found

C.

1 Found

D.

3 Found

Buy Now
Questions 49

Given the following code:

What is the output?

Options:

A.

44

B.

35

C.

47

D.

54

E.

45

F.

421

Buy Now
Questions 50

Which three are advantages of the Java exception mechanism? (Choose three.)

Options:

A.

Improves the program structure because the error handling code is separated from the normal program function

B.

Provides a set of standard exceptions that covers all possible errors

C.

Improves the program structure because the programmer can choose where to handle exceptions

D.

Improves the program structure because exceptions must be handled in the method in which they occurred

E.

Allows the creation of new exceptions that are customized to the particular program being created

Buy Now
Questions 51

Given the code fragments:

Which code fragment, when inserted at line n1, enables the code to print Hank?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Buy Now
Questions 52

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

Buy Now
Questions 53

Given:

What is the result?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Buy Now
Questions 54

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.

Buy Now
Questions 55

Given this segment of code:

Which two statements, if either were true, would make the code compile? (Choose two.)

Options:

A.

MotorCycle is an interface that implements the Cycle class.

B.

Cycle is an interface that is implemented by the MotorCycle class.

C.

Cycle is an abstract superclass of MotorCycle.

D.

Cycle and MotorCycle both extend the Transportation superclass.

E.

Cycle and MotorCycle both implement the Transportation interface.

F.

MotorCycle is a superclass of Cycle.

Buy Now
Questions 56

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

Buy Now
Questions 57

Given:

and the code fragment:

S2 sobj = new S2(); sobj.display(10, 100);

What is the result?

Options:

A.

Child 10

Child 100

Parent 100

B.

Parent 10

Child 10

Parent 1000

C.

Child 10

Parent 100

Parent 100

D.

A compile time error occurs.

Buy Now
Questions 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

Buy Now
Questions 59

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.

Buy Now
Questions 60

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

Buy Now
Questions 61

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.

Buy Now
Questions 62

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

Buy Now
Questions 63

Given:

What is the result?

Options:

A.

Hello Log 2:2

B.

Welcome Log 1:2

C.

Welcome Log 2:1

D.

Hello Log 1:2

Buy Now
Questions 64

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.

Buy Now
Questions 65

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.

Buy Now
Questions 66

Given the code fragment:

Which two code fragments inserted at line 10 print ****?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Buy Now
Questions 67

Given the code fragments:

Which modification enables the code to compile?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Buy Now
Exam Code: 1z0-808
Exam Name: Java SE 8 Programmer I
Last Update: Jun 15, 2025
Questions: 224
1z0-808 pdf

1z0-808 PDF

$29.75  $84.99
1z0-808 Engine

1z0-808 Testing Engine

$35  $99.99
1z0-808 PDF + Engine

1z0-808 PDF + Testing Engine

$47.25  $134.99