wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java Quiz 3: Object-Oriented Programming Concepts

Total questions: 8

Worksheet time: 24mins

Name
Class
Date
1.

What will be displayed when the following statements are run:

int limit=20;

int Sum=20;

if(sum>limit)

System.out.print("Limit surpassed");

else

System.out.print("Limit not ");

System.out.print("reached.");

a)

Limit surpassed

b)

Limit surpassed reached.

c)

Limit not

d)

Limit not reached.

2.

When comparing strings, which method can be used to see if two strings contain the same string?

a)

length()

b)

compareTo()

c)

equals()

d)

indexOf()

3.

What will the following code display when run?

String str1="Melvin";

String str2="Melvin";

if(str1!=str2)

System.out.print("I didn't expect that.");

else

System.out.print("This one is tricky.");

a)

I didn't expect that.

b)

This one is tricky.

4.

To compare if two string are the same we can use the == operator.

a)

True

b)

False

5.

A setter methods gives a data field its value

a)

True

b)

False

6.

A getter methods will retrieve values from a data field.

a)

True

b)

False

7.

To use a Scanner we need to create a new Scanner object.

a)

True

b)

False

8.

To get something other than a string from an input dialog box we need to parse the string into the appropriate data type.

a)

True

b)

False