Exit demo 1Z0-811 Java Foundations PDF format · free preview

Oracle 1Z0-811 - Questions & Answers

Free preview · every answer includes a full explanation

Product page: https://prepkeys.com/1z0-811.html

Question 1
Single choice

Which statement is true about primitive variables?

A.

They can be compared with the == operator.

B.

They can be compared with the equals method only.

C.

They cannot be compared.

D.

They can be compared with the compareTo method only.

Question 2
Single choice

Given the code fragment:

What is the result?

A.

2

B.

4

C.

The program executes an infinite number of times.

D.

3

Question 3
Multiple choice

Identify two Java reserved words.

A.

array

B.

true

C.

this

D.

exception

E.

string

Question 4
Single choice

Which statement is true about a Java method?

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.

Question 5
Single choice

Given:

And the code fragment:

Which code fragment can be inserted at line n1 to enable the code to print All the best?

A.

void writeMsg();

B.

Messenger.writeMsg();

C.

writeMsg();

D.

m.writeMsg();

Question 6
Multiple choice

Given the code fragment:

Which two code fragments are valid at line 2?

A.

for (int count = 0; count < 5; count++) {

System.out.print(count);
}

B.

package p1;

C.

import java.util.*;
public void display() {
List<Integer> nums = new ArrayList<> ();
}

D.

{
private int num;
}

E.

private String name = "John";
public void display() {
System.out.print(name);
}

Question 7
Single choice

You have been asked to develop a Java program that prints the elements of an array in reverse order.

Which looping statement cannot be used to meet the requirement?

A.

enhanced for

B.

standard for

C.

while

D.

do-while

Question 8
Single choice

Given the code fragment:

Which statement is true?

A.

The code results in a compilation error. To make it compile, insert at line n1:
import java.lang.Math;
import java.lang.Random;

B.

The code compiles successfully

C.

The code results in a compilation error. To make it compile, insert at line n1:
import java.lang;
import java.util;

D.

The code results in a compilation error. To make it compile, insert at line n1:
import java.util.*;

Question 9
Single choice

Given the code fragment:

What is the result?

A.

pen pencil erasers paper

B.

paper pen pencil erasers

C.

A compilation error occurs.

D.

A runtime exception is thrown.

Question 10
Single choice

Given the code fragment:

Which code fragment, when inserted at line n1, enables the code to print Java Programming:1?

A.

System.out.println(name + ":" + count);

B.

System.out.println(c.name + ":" + count);

C.

System.out.println(c.name + ":" + Course.count);

D.

System.out.println(Course.name + ":" + c.count);

Showing 10 of 75 questions · Unlock the full set