wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java Quiz 2: Classes and Objects

Total questions: 10

Worksheet time: 30mins

Name
Class
Date
1.

In Java null is:

a)

The initial value of an object variable.

b)

A key word

c)

A value that means not pointing to any object

d)

All of these

e)

None of these

2.

In Java an object is:

a)

A key word

b)

A software concept used to model various things in programs, which have states, behaviors and attributes given to them

c)

A primitive data type

d)

None of these

3.

Classes in Java are:

a)

Abstract data types, used as a template of objects

b)

Where students learn

c)

Dungeons and Dragons Character types

d)

None of these

4.

The following string "Hello, World!" is stored in String str.

What will str.indexOf("ll") return?

a)

0

b)

1

c)

2

d)

3

5.

The string method length() returns what?

a)

The size in memory of the string

b)

The number of symbols in a string

c)

How long the biggest word is

d)

A measurement of how long the program has run

6.

When using the indexOf() method, what will be returned when looking for something not contained within the string?

a)

-1

b)

0

c)

1

d)

not found

e)

false

7.

To create an object in java we use the keyword new.

a)

True

b)

False

8.

To assign values to variables in Java we use an equal sign.

a)

True

b)

False

9.

isEmpty() will return true if a string is only contains whitespace.

a)

True

b)

False

10.

We use void to signify that a method does not return any data.

a)

True

b)

False