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

Oracle 1z0-811 Java Foundations Exam Practice Test

Page: 1 / 8
Total 75 questions

Java Foundations Questions and Answers

Question 1

Identify two class variables.

Options:

A.

private static int numberOfSquares = 20;

B.

public static int counter = 0;

C.

private Measure cm;

D.

public int size = 10;

E.

int scale = 35;

Question 2

Given the code fragment:

Question # 2

Which statement, when inserted at line n1, enables the code to print 0 2 4 6 8 10?

Options:

A.

count = (count++) +1;

B.

count = count++;

C.

count =+ 2;

D.

count += 2;

Question 3

Which statement is true about a mutator method?

Options:

A.

It replaces the default constructor.

B.

It returns mutated instance members.

C.

It must be declared private.

D.

It can be used to assign data to instance members.

Question 4

Given the code fragment:

Question # 4

What is the result?

Options:

A.

Selected null flavor.

B.

Selected Chocolate flavor.

C.

An ArrayIndexOutofBoundsException is thrown at run time.

D.

Selected Chocolate flavor.

Thank you!

Question 5

Given the code fragment:

Question # 5

What is the result?

Options:

A.

a memory address1 in hexadecimal number format

a memory address2 in hexadecimal number format

B.

10, 15

[10, 15]

C.

0, 10, 15

[10, 15, null]

D.

a memory address in hexadecimal number format

[10, 15]

Question 6

Given the code fragment:

Question # 6

What is the result?

Options:

A.

false

true

B.

true

true

C.

false

false

D.

A runtime exception is thrown

Question 7

Given the code fragment:

Question # 7

What is the result?

Options:

A.

10

B.

11

C.

12

D.

13

Question 8

Given:

Question # 8

What is the result?

Options:

A.

20

B.

32

C.

A compilation error occurs.

D.

21

Question 9

Given the code fragment:

Question # 9

What is the result?

Options:

A.

A compilation error occurs at line n1.

B.

Jack

C.

The program prints either Jack or Queen.

D.

Queen

Question 10

Given the code fragment:

Question # 10

Which code fragment, when inserted at line n1, enables it to print Rita is 14 years old?

Options:

A.

System.out.println(“%s is %d years old” +name+age);

B.

System.out.println(“%s is %n years old” name, age);

C.

System.out.printf(“%s is %d years old”, name, age);

D.

System.out.printf(“%s is %n years old”, name, age);

Question 11

Which statement is true about a Java method?

Options:

A.

It must be declared with an access modifier.

B.

It cannot be defined within another method.

C.

It must accept a parameter and return a value.

D.

It cannot be defined as static final.

Page: 1 / 8
Total 75 questions