wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java

Total questions: 25

Worksheet time: 14mins

Name
Class
Date
1.

Which of the following is the best description of a "relational operator"?

a)

Comparison symbols used in logical expressions

b)

Mathematical symbols used to calculate numeric results

c)

Links that control the relationships between objects

d)

None of these are true

2.

Which of the following is the best description of a "relational operator"?

a)

Comparison symbols used in logical expressions

b)

Mathematical symbols used to calculate numeric results

c)

Links that control the relationships between objects

d)

None of these are true

3.

Given two numbers A and B, which of the following expressions will be true when "A is less than B"?

a)

A < B

b)

A > B

c)

A == B

d)

A != B

4.

Given two numbers A and B, which of the following expressions will be true when "A is equal to B"?

a)

A != B

b)

A == B

c)

A = B

d)

A.eq(B)

5.

How many times will the following code print "Welcome to Java"?
int count = 0;
while (count <= 10) {
 System.out.println("Welcome to Java");
 count++;
}

a)
8
b)
9
c)
10
d)
0
6.

What will this code display?


int i = 0;

do { System.out.print (i + ", ");

} while (i < 5);

a)

0, 0, 0, 0, 0, 0, 0, 0, (repeat forever)

b)

0, 1, 2, 3, 4,

c)

1, 2, 3, 4, 5,

d)

Compile error

e)

10,

7.

True/False Do-while loops can be nested inside of other loops.

a)

True

b)

False

8.

Which of the following is a type of polymorphism in Java?

a)

Compile time polymorphism

b)

Execution time polymorphism

c)

Multiple polymorphism

d)

Multilevel polymorphism

9.

Which of these keywords is used to make a class?

a)

class

b)

struct

c)

int

d)

none of the mentioned

10.

x /= 3


Which of the below statements matches with above statement?

a)

x = 3 / x

b)

x = x / 3

c)

x / 3

d)

x /x = 3

11.

Which of the following is assignment operator?

a)

==

b)

=

c)

=+

d)

++

12.

Which of the following is the right way of defining char variable?

a)

char myGrade = 'B';

b)

char myGrade = "B";

c)

char myGrade 'B';

d)

char myGrade = "B"

13.

which of the following is NOT a primitive data type?

a)

byte

b)

array

c)

char

d)

boolean

14.

Which of the following is NOT a NON-primitive data type

a)

String

b)

Array

c)

double

d)

class

15.
What does a comment look like in Java?
a)
//comment
b)
\\comment
c)
==comment
d)
\comment
16.
What is at the end of a line of code?
a)
#
b)
;
c)
)
d)
>
17.
When we want to print in Java, we use the code ......
a)
System.out.println();
b)
System.Out.Printf();
c)
System.out.show();
d)

System.out.print();

18.
A variable that holds a whole number
a)
String
b)
boolean
c)
int
d)
float
19.

Which of the following is incorrect?

a)

int count = 5o.0;

b)

int salary = 50_000;

c)

int salary = 50_00;

d)

all of these are incorrect

20.

__________ is needed to access a method in a class.

a)

class name

b)

class variable

c)

function

d)

object

21.

main method is a

a)

non static method

b)

static method

22.

Which of the following class is used to read input during execution?

a)

Array

b)

String

c)

Scanner

d)

Main

23.

Syntax for main method

a)

void main()

b)

void main(String[] args)

c)

public static void main(String[] args)

d)

public main(String[] args)

24.

Java runs on

a)

Unix/Linux

b)

Macintosh

c)

Windows

d)

All of the above

25.

int z=1.5;

What will be the value of z?

a)

z=1.5

b)

run time error

c)

compilation error

d)

z=1.15