Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaLab-2Quiz

Total questions: 21

Worksheet time: 9mins

Name
Class
Date
1.

What type of language is Java?

a)

Object Oriented

b)

Scripting

c)

Assembly

d)

Pseudocode

2.

Which keyword is used to create an object in Java?

a)

create

b)

object

c)

new

d)

make

3.

What is the correct way to declare a variable of type double in Java?

a)

double variableName

b)

boolean variableName

c)

String variableName

d)

int variableName

4.

What is the correct way for storing WHOLE numbers in Java?

a)

float num = 5.0

b)

int num = 5;

c)

double num = 5.0

d)

string num = "5";

5.

What is the output of z?

int x = 5;

int y = 2;

int z = x/y;

a)

2.5

b)

2.50

c)

2

d)

ERROR

6.

Which of the following data types stores characters in Java?

a)

int

b)

double

c)

char

d)

boolean

7.

What is a correct syntax to output "Hello World" in Java?

a)

System.out.println("Hello World");

b)

Console.WriteLine("Hello World");

c)

echo("Hello World");

d)

print ("Hello World");

8.

How do you insert COMMENTS in Java code?

a)

// This is a comment

b)

# This is a comment

c)

/* This is a comment

9.

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

a)

String

b)

string

c)

Txt

d)

myString

10.

Which operator can be used to compare two values?

a)

==

b)

=

c)

<>

d)

><

11.

Select wrong identifier in JAVA

a)

all_member

b)

_$_$

c)

total123

d)

123total

12.

Size of BYTE datatype

a)

2 byte

b)

8-bits

c)

4 byte

d)

8 byte

13.

Java program does not run without below function

a)

user()

b)

system()

c)

main()

d)

void()

14.

A ___________ file is created after successful compilation of a Java program.

a)

Object file

b)

Array file

c)

Class file

d)

String file

15.

Command to compile Java program

a)

javax

b)

javay

c)

javac

d)

Java

16.

Command to run a Java program

a)

javaa

b)

java

c)

jaava

d)

jaavaa

17.

JDK stands for

a)

Java Developer Kit

b)

Java Development Kit

c)

Java Design Kit

d)

Java Debugging Kit

18.

JRE stands for

a)

Java Run Environment

b)

Java Run Execution

c)

Java Runtime Environment

d)

Java Ready Execution

19.

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

a)

byte x = 2.8f

b)

float x = 2.8f;

c)

x = 2.8f;

d)

int x = 2.8f;

20.

Which keyword is used to import a package from the Java API library?

a)

lib

b)

import

c)

getlib

d)

package

21.

Which statement is true about java ?


a)

Java is a sequence-depended programming language


b)

Java is a code dependent programming language


c)

Java is a platform-dependent programming language


d)

Java is a platform-independent programming language