New Year Special Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: 70special

Oracle 1z0-811 Java Foundations Exam Practice Test

Page: 1 / 8
Total 75 questions

Java Foundations Questions and Answers

Testing Engine

  • Product Type: Testing Engine
$37.5  $124.99

PDF Study Guide

  • Product Type: PDF Study Guide
$33  $109.99
Question 1

Given the code fragment:

What is the result?

Options:

A.

3

B.

A compilation error occurs.

C.

2

D.

0

Question 2

Given the code fragment:

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 3

Given the code fragment:

What is the result?

Options:

A.

10 20

10 15 20

B.

A runtime exception is thrown.

C.

10 20

10 20

D.

A compilation error occurs.

Question 4

Given the code fragment:

What is the result?

Options:

A.

1

B.

3

C.

5

D.

Nothing is printed.

Question 5

Given the code fragment:

Which for loop statement can be used to print 135?

Options:

A.

for(int idx = 1; idx < arr.length; idx+=2) {

System.out.print (arr[idx]);

}

B.

for(int idx = 1; idx < arr.length–1; idx++) {

System.out.print (arr[idx++]);

}

C.

for(int idx = 0; idx < arr.length; idx++) {

System.out.print (arr[idx]);

}

D.

for(int idx = 0; idx < arr.length; idx+=2) {

System.out.print (arr[idx]);

}

Question 6

Given the code fragment:

What is the result?

Options:

A.

3 : 1

B.

3 : 2

C.

0 : 1

D.

2 : 0

Question 7

Given the code fragment:

What is the result?

Options:

A.

false

false

false

false

B.

true

false

false

false

C.

true

true

true

true

D.

true

true

true

false

Question 8

Given:

What is the result?

Options:

A.

The code fails to compile. To make it compile, at line n1 insert:

this () { }

B.

The code fails to compile. To make it compile, at line n2 insert:

this ();

C.

The code fails to compile. To make it compile, at line n1 insert:

Bus () { }

D.

The code compiles and prints:

default

luxury

Question 9

Given:

What is the result?

Options:

A.

Compilation fails. To make it compile, replace line n1 with var1 = 0;

B.

Compilation fails. To make it compile, replace line n2 with var2 = 0;

C.

0

D.

Nothing is printed.

Question 10

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 11

What is the meaning of “write once, run anywhere” in Java?

Options:

A.

Java programs are designed to run only in web browsers and, thus, can run wherever there is a browser.

B.

It is a marketing statement because Java programs must be compiled for a specific platform in order to run.

C.

Java programs can run on any Java Virtual Machine without being recompiled.

D.

Java programs, after being compiled, can run on any platform or device even without a Java Virtual Machine.

Page: 1 / 8
Total 75 questions