wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Gamified Quiz

Total questions: 69

Worksheet time: 43mins

Name
Class
Date
1.

Polymorphism related to :

a)

PPO

b)

Class

c)

OPP

d)

OOP

2.

The process by which objects of one class acquire the properties of objects of another class is known as

a)

Polymorphism

b)

Inheritance

c)

Data Hiding

d)

Association

3.
An object is an instance of a:
a)
parameter
b)
method
c)
class
d)
application
4.

Which of the these is the functionality of ‘Encapsulation’?

a)

Binds together code and data

b)

Using single interface for general class of actions

c)

Reduce Complexity

d)

All of the mentioned

5.

How do you create a variable with the numeric value 5?

a)

float x = 5;

b)

x = 5;

c)

int x = 5;

d)

num x = 5

6.

Which data type is used to create a variable that should store text?

a)

myString

b)

String

c)

Txt

d)

string

7.

How do you insert COMMENTS in Java code?

a)

# This is a comment

b)

/* This is a comment

c)

// This is a comment

8.

Java is short for "JavaScript".

a)

true

b)

false

9.

How do you create a variable with the floating number 2.8?

a)

byte x = 2.8f

b)

x = 2.8f;

c)

float x = 2.8f;

d)

int x = 2.8f;

10.

The value of a string variable can be surrounded by single quotes.

a)

true

b)

false

11.

How do you write a Single Liner Comment in Java?

(a)  

12.

Which operator is used to add together two values?

(a)  

13.

Which part of this for-statement tells how a variable or initial expression is changed or updated with every loop.

(a)  

14.

What is the logical operator NOT?

(a)  

15.

What Java Package contains the class - Scanner.

(a)  

16.

Which operator can be used to compare two values?

a)

><

b)

=

c)

==

d)

<>

17.

Which keyword is used to return a value inside a method?

a)

return

b)

void

c)

break

d)

get

18.

1. Which of this method is given parameter via command line arguments?

a)

a) main()

b)

b) recursive() method

c)

c) Any method

d)

d) System defined methods

19.

What are the Type Conversions available in Java language?

a)

A) Narrowing Type Conversion

b)

B) Widening Type Conversion

c)

A and B

d)

D) None of the above

20.

Which type of loop is best known for its boolean condition that controls entry to the loop?

a)

A. do-while loop

b)

B. for (traditional)

c)

C. for-each

d)

D. while

21.

What will be the Output of the below code:

public class Demo{

public static void main(String[] arr){

}

public static void main(String arr){

}

}

a)

a) Nothing

b)

b) Error

c)

C) Finite

d)

d) Hii

22.

char is 2 byte in storage?

a)

True

b)

False

23.

What data type would you use for storing the number of students in a class?

a)

boolean

b)

String

c)

double

d)

int

24.
What data type would be best used to record an email address?
a)
String
b)
Integer
c)
Real
d)
Character
25.

What is the output of the following code snippet?

int i = 0; for(i = 0 ; i < 5; i++)

{ }

System.out.println(i);

a)

A. 5

b)

B. 0

c)

C. 4

d)

D. Compilation Error

26.

Find the output for the following.

public class IncDec

{

public static void main(String s[])

{

int a = 1;

int b = 2;

int c;

int d;


c = ++b;

d = a++;


c++;


System.out.println("a = " + a);

System.out.print("b = " + b);

System.out.println("c = " + c);

System.out.print("d = " + d);

}

}

a)

a = 2 b = 3 c = 4 d = 1

b)

a = 2 b = 3 c = 4 d = 1

c)

Program does not compile.

d)

a = 1 b = 2 c = 4 d = 2

27.

Is String a primitive data type?

a)

Yes

b)

No

c)

Both

28.

String txt = "Hello World";

System.out.println(txt.toUpperCase());


Choose the correct output.

a)

"HELLO WORLD"

b)

HELLO WORLD

c)

Hello world

d)

Hello World

29.

What is the return type of equalsIgnorecase() method?

a)

int

b)

String

c)

char

d)

boolean

30.

int a = 7;

int b = 2 + a;

a)

b = 9

b)

b = 2

c)

b = 7

d)

b = 5

31.

int a = 5;

a++;

What is a now?

a)

4

b)

7

c)

5

d)

6

32.

int a = 5;

a--;

What is a now?

a)

4

b)

3

c)

5

d)

6

33.

int x = 4;

x *= 10;

Which is true?

a)

x is now 40

b)

x is now 10

c)

x is still 4

d)

x is now 14

34.

A while loop carries on as long as...

a)

The condition in the brackets is true

b)

The condition in the brackets is false

c)

i < 10

d)

the for loop has not ended

35.

A while loop has the following format:

a)

while (condition)

{

...

}

b)

while

{

...

}

c)

continue while (condition)

{

...

}

d)

while [condition]

[

...;

]

36.

OUTPUT?

int i = 1;

while (i < 5) {

System.out.println("Hello");

i++;

}

a)

Hello

Hello

Hello

Hello

Hello

b)

Hello

Hello

Hello

Hello

c)

Hello

Hello

Hello

d)

Hello

37.

How many times does the loop print a *

a)

40

b)

20

c)

24

d)

30

e)

Infinite Loop

38.
True/False
If a loop condition is never satisfied then the loop does not execute.
a)
True
b)
False
39.

How many times does the following method print a *?

a)

9

b)

6

c)

7

d)

10

40.

2

a)

5

b)

7

c)

9

d)

13

e)

20

41.

JAVA : I want to change this operation into division. What symbol should I choose?

a)

/

b)

÷\div  

c)

\parallel  

d)

*

42.

JAVA : I want to change this operation into subtraction. What symbol should I choose?

a)

/

b)

c)

\parallel  

d)

*

43.

JAVA : What is the output for this operation?

a)

6

b)

7

c)

5

44.

JVM stands for____

a)

Java Volume Member

b)

Java Virtual Machine

c)

Java Vending Machine

d)

None of the above

45.

Java is a/an ___

a)

Structured Programming language

b)

Object-oriented Programming Language

c)

Query Language

d)

All of the above

46.

What is shown in the diagram?

a)

Tea

b)

Coffee

c)

Boiled Water

d)

Acid

47.

Which statement is true about java?

a)

Platform independent programming language

b)

Platform dependent programming language

c)

Code dependent programming language

d)

Sequence dependent programming language

48.

What is the extension of java code files?

a)

.class

b)

.java

c)

.txt

d)

.js

49.

Which company owns Java?

a)

Oracle

b)

Microsoft

c)

Google

d)

Apple

e)

Intel

50.
a)

A. Compile Time Error

b)

B. It will print 'Show'

c)

C. No Output

d)

D. Runtime Error

51.

5 + 5 =

a)

10

b)

0

c)

25

52.

5%5 =

a)

0

b)

25

c)

1

53.

What would be displayed on the console:

System.out.print("Help!")

System.out.println("I forgot my password")

a)

Error

b)

Help! I forgot my password.

c)

Help!

I forgot my password.

54.

(a)   number = 10;

55.

(a)   result = 10 > 0 ;

56.

(a)   name = "ARMY";

57.

(a)   .out.println();

58.

(a)   number = "12345";

59.

Public static void (a)   (String[] args)

60.

(a)   Name = 120;

61.

String number = _1234_;

(a)  

62.

String surname = "good"_

(a)  

63.

Determine the output of this Java program.

(a)  

64.

How many times is "Hi.." printed?

a)

10

b)

15

c)

8

d)

Infinite Loop

65.

Java was originally named:

a)

Coffee

b)

Oak

c)

New C++

d)

Duke

66.

What is the name of the Java mascot?

a)

Duke

b)

Ronny

c)

Penguin

d)

James

e)

Jack

67.

Before Java, it is called?

a)

Oak

b)

JavaScript

c)

Jazz

d)

Shrub

68.

A software development environment used for developing Java applications.

a)

Java Runtime Environment

b)

Java Development Kit

c)

Java Compiler

d)

Java Virtual Machine

69.

It  is responsible for executing the java program line by line, hence it is also known as an interpreter.

a)

Java Runtime Environment

b)

Java Development Kit

c)

Java Compiler

d)

Java Virtual Machine