Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

OCA Test I

Total questions: 10

Worksheet time: 10mins

Name
Class
Date
1.

Which of the following are true? (Choose all that apply)

a)

javac compiles a .class file into a .java file.

b)

javac compiles a .java file into a .bytecode file.

c)

javac compiles a .java file into a .class file.

d)

Java takes the name of the class as a parameter.

e)

Java takes the name of the .bytecode file as a parameter.

2.

Which of the following are true statements? (Choose all that apply)

a)

Java allows operator overloading.

b)

Java code compiled on Windows can run on Linux.

c)

Java has pointers to specific locations in memory.

d)

Java is a procedural language.

e)

Java is an object-oriented language

3.
a)

0

b)

4

c)

Compilation fails on line 3

d)

Compilation fails on line 4

e)

Compilation fails on line 8

4.

Which represent the order in which the following statements can be assembled into a program

that will compile successfully? (Choose all that apply)

A: class Rabbit {}

B: import java.util.*;

C: package animals;

a)

A, B, C

b)

B, C, A

c)

C, B, A

d)

B, A

e)

C, A

5.
a)

Bunny is a class

b)

bun is a class

c)

main is a class

d)

Bunny is a reference to an object

e)

bun is a reference to an object

6.

a)

int amount = 9L;

b)

int amount = 0b101;

c)

int amount = 0xE;

d)

double amount = 0xE;

e)

double amount = 1_2_.0_0;

7.

Which of the following lines of code compile? (Choose all that apply)

a)

int i1 = 1_234;

b)

double d1 = 1_234_.0;

c)

double d2 = 1_234._0;

d)

double d3 = 1_234.0_;

e)

double d4 = 1_234.0;

8.

Which of the following are true? (Choose all that apply)

a)

An instance variable of type boolean defaults to false.

b)

An instance variable of type boolean defaults to true.

c)

An instance variable of type boolean defaults to null.

d)

An instance variable of type int defaults to 0.

e)

An instance variable of type int defaults to 0.0.

9.

Which of the following are true? (Choose all that apply)

a)

A local variable of type boolean defaults to null.

b)

A local variable of type float defaults to 0.

c)

A local variable of type Object defaults to null.

d)

A local variable of type boolean defaults to false.

e)

None of the above.

10.

Which of the following method signatures is a valid declaration of an entry point in a

Java application?

a)

public void main(String[] args)

b)

public static void main()

c)

private static void start(String[] mydata)

d)

public static final void main(String[] mydata)

e)

None of the above