Labour Day Special Limited Time Flat 70% Discount offer - Ends in 0d 00h 00m 00s - Coupon code: 70spcl

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

Question 1

Given:

Acc.java:

Question # 1

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 2

Given the code fragment:

Question # 2

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 3

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 4

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 5

Given:

Question # 5

What is the result?

Options:

A.

Welcome Visit Count:0Welcome Visit Count: 1

B.

Compilation fails at line n2.

C.

Compilation fails at line n1.

D.

Welcome Visit Count:0Welcome Visit Count: 0

Question 6

Given the code fragment from three files:

Question # 6

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

Question # 6

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 7

Given:

Question # 7

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.

Question 8

Given the code fragment:

Question # 8

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 9

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 10

Given:

Question # 10

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 11

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?

Question # 11

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 12

Given the definitions of the Bird class and the Peacock class:

Question # 12

and the code fragment:

Question # 12

Which code snippet can be inserted to print Fly.Dance. ?

Options:

A.

Bird p = new Peacock();

B.

Bird b = new Bird();Peacock p = (Peacock) b;

C.

Peacock b = new Peacock ();Bird p = (Bird) b;

D.

Bird b = new Peacock ();Peacock p = (Peacock) b;

Question 13

Given this segment of code:

Question # 13

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.

Question 14

Given the code fragment:

Question # 14

What is the result?

Options:

A.

11

B.

10

C.

12

D.

A compile time error occurs.

Question 15

Given the code fragment:

Question # 15

Which two modifications, when made independently, enable the code to print Joe:true: 100.0? (Choose two.)

Question # 15

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 16

Given the code fragment:

Question # 16

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 17

Given:

Question # 17

What is the result?

Options:

A.

true

B.

false

C.

-1

D.

0

Question 18

Given the code fragment:

Question # 18

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 19

Given:

Question # 19

What is the result?

Options:

A.

Compilation fails at line n1.

B.

InitializedStartedInitialized

C.

InitializedStarted

D.

Compilation fails at line n2.

Question 20

Given the code fragment:

Question # 20

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 21

Given:

Question # 21

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

Question 22

Given:

Question # 22

What is the result?

Options:

A.

myStr: 7007, myNum: 7007

B.

Error

C.

myStr: 9009, myNum: 7007

D.

myStr: 7007, myNum: 9009

Question 23

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

Question # 23

What is the result?

Question # 23

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 24

Given:

Question # 24

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 25

Given these classes:

Question # 25

And given this main method:

Question # 25

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 26

Given:

Question # 26

What is the result?

Options:

A.

true:true

B.

true:false

C.

false:true

D.

false:false

Question 27

Given the code fragment:

Question # 27

Test.java:

Question # 27

Which is the result?

Question # 27

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 28

Given the code fragments:

Question # 28

Which modification enables the code to compile?

Question # 28

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 29

Given the code fragment:

Question # 29

What is the result?

Options:

A.

An exception is thrown at runtime.

B.

-1

C.

5

D.

10

Question 30

Given the code fragment:

Question # 30

Which code fragment at line 10 prints Welcome 100?

Question # 30

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 31

Given these requirements:

  • Bus and Boat are Vehicle type classes.
  • The start() and stop() methods perform common operations across the Vehicle class type.
  • The ride() method performs a unique operations for each type of Vehicle.

Which set of actions meets the requirements with optimized code?

Options:

A.

1. Create an abstract class Vehicle by defining start() and stop() methods, and declaring the ride()

abstract method.

2. Create Bus and Boat classes by inheriting the Vehicle class and overriding the ride() method.

B.

1. Create an interface Vehicle by defining start() and stop() methods, and declaring the ride()

abstract method.

2. Create Bus and Boat classes by implementing the Vehicle class.

C.

1. Create an abstract class Vehicle by declaring stop(), start(), and ride() abstract methods.

2. Create Bus and Boat classes by inheriting the Vehicle class and overriding all the methods.

D.

1. Create an interface Vehicle by defining default stop(), start(), and ride() methods.

2. Create Bus and Boat classes by implementing the Vehicle interface and overriding the ride()

method.

Question 32

Given the code fragment:

Question # 32

What is the result?

Options:

A.

1:2:3:4:5:

B.

1:2:3:

C.

Compilation fails.

D.

An ArrayOutOfBoundsException is thrown at runtime.

Question 33

Given:

Question # 33

And the code fragment:

Question # 33

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

Question # 33

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 34

Given:

Question # 34

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 35

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 36

Given the code fragment:

Question # 36

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 37

Examine the content of App.java:

Question # 37

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 38

Which two statements are true? (Choose two.)

Options:

A.

Error class is unextendable.

B.

Error class is extendable.

C.

Error is a RuntimeException.

D.

Error is an Exception.

E.

Error is a Throwable.

Question 39

Given the code fragment:

Question # 39

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 40

Given the code fragment:

Question # 40

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:

Question # 41

What is the result?

Options:

A.

Compilation fails.

B.

false true

C.

true false

D.

true true

E.

false false

Question 42

Given this array:

Question # 42

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

Question # 42

Question # 42

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

F.

Option F

Question 43

Given the code fragment:

Question # 43

What is the result?

Options:

A.

AB

B.

A element 0B element 1

C.

A NullPointerException is thrown at runtime.

D.

A 0B 1

Question 44

Given the code fragment:

Question # 44

What is the result?

Options:

A.

2 4

B.

0 2 4 6

C.

0 2 4

D.

Compilation fails.

Question 45

Given the code fragment:

Question # 45

What is the result?

Options:

A.

1 2 3 0 01 2 3 0 0

B.

An Exception is thrown at run time.

C.

1 2 3 0 01 2 3

D.

1 2 31 2 3

Question 46

Given the code fragment:

Question # 46

What is the result?

Options:

A.

1 3 5 71 3

B.

1 31 3

C.

1 31 3 0 0

D.

1 3followed by an ArrayIndexOutOfBoundsException

E.

Compilation fails.

Question 47

Given the code fragment:

Question # 47

What is the result?

Options:

A.

An exception is thrown at runtime.

B.

2014-07-31T01:01:00

C.

2014-07-31

D.

2014-09-30T00:00:00

Question 48

This grid shows the state of a 2D array:

Question # 48

The grid is created with this code:

Question # 48

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

Question 49

Given the code fragment:

Question # 49

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

Question # 49

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 50

Given the following code:

Question # 50

What is the output?

Options:

A.

44

B.

35

C.

47

D.

54

E.

45

F.

421

Question 51

Given the code fragment:

Question # 51

What is the result?

Options:

A.

Answer = 0

B.

Invalid calculation

C.

Compilation fails only at line n1.

D.

Compilation fails only at line n2.

E.

Compilation fails at line n1 and line2.

Question 52

Given:

Question # 52

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

Question # 52

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 53

Given:

Question # 53

and the code fragment:

Question # 53

What is the result?

Options:

A.

true:false:true

B.

false:true:true

C.

false:true:false

D.

true:true:false

Question 54

Given:

Question # 54

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.

Question 55

Given:

Question # 55

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 56

Given the code fragment:

Question # 56

What is the result?

Options:

A.

[JavaForum, ExpertForum]

B.

[JavaGroup, ExpertGroup]

C.

[JavaForumGroup, ExpertForumGroup]

D.

[JavaGroup, TechGroup ExpertGroup]

Question 57

Given the code fragment:

Question # 57

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 58

Given the code fragment:

Question # 58

What is the result?

Options:

A.

[green, red, yellow, cyan]

B.

[green, blue, yellow, cyan]

C.

[green, red, cyan, yellow]

D.

An IndexOutOfBoundsException is thrown at runtime.

Question 59

Given the code fragment:

Question # 59

What is the result?

Options:

A.

An exception is thrown at runtime.

B.

2014-07-31T01:01:00

C.

2014-07-31

D.

2014-09-30T00:00:00

Question 60

Given the code fragment:

Question # 60

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 61

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

Question # 61

What is the result?

Question # 61

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 62

Given:

Question # 62

And given the code fragment:

Question # 62

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 63

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 64

Given:

Question # 64

What is the result?

Options:

A.

a, ei, i

B.

a, eo, o

C.

e, ei, i

D.

a, ao, o

Question 65

Given the code fragment:

Question # 65

What is the result?

Options:

A.

Compilation fails.

B.

0 Found

C.

1 Found

D.

3 Found

Question 66

Given the code fragment:

Question # 66

What is the result?

Options:

A.

EN FR JP

B.

EN FR

C.

CH

D.

EN FR CH

Question 67

You are asked to create a method that accepts an array of integers and returns the highest value from that array.

Given the code fragment:

Question # 67

Which method signature do you use at line n1?

Options:

A.

public int findMax (int[] numbers)

B.

static int[] findMax (int[] max)

C.

static int findMax (int[] numbers)

D.

final int findMax (int[] )

Page: 1 / 22
Total 224 questions