wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java MCQs – Introduction, Variables, and Data Types

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Java was originally developed by:

a)

Microsoft

b)

Apple

c)

Sun Microsystems

d)

IBM

2.

Which principle makes Java platform-independent?

a)

Object-Oriented

b)

Robust

c)

Write Once, Run Anywhere

d)

Secure

3.

Which component converts Java source code into bytecode?

a)

JVM

b)

JRE

c)

JIT

d)

Compiler (javac)

4.

Which method is the entry point of a Java program?

a)

start()

b)

main()

c)

run()

d)

execute()

5.

Which keyword is used to define a class in Java?

a)

define

b)

class

c)

struct

d)

object

6.

A variable declared inside a method is called:

a)

Instance variable

b)

Static variable

c)

Local variable

d)

Global variable

7.

Which keyword is used to declare a static variable?

a)

final

b)

public

c)

static

d)

private

8.

Which of the following is a valid variable name in Java?

a)

1number

b)

total marks

c)

class

d)

_count

9.

Which data type is used to store whole numbers by default?

a)

byte

b)

short

c)

int

d)

long

10.

Size of int data type in Java is:

a)

2 bytes

b)

4 bytes

c)

8 bytes

d)

1 byte

11.

Which data type is used to store true or false values?

a)

boolean

b)

char

c)

int

d)

float

12.

Which symbol is used to store single characters?

a)

" "

b)

{ }

c)

' '

d)

[ ]

13.

Which data type requires suffix 'f' while assigning value?

a)

double

b)

long

c)

float

d)

int

14.

Which of the following is NOT a primitive data type?

a)

int

b)

float

c)

String

d)

char

15.

Which non-primitive data type is used to store text?

a)

char

b)

String

c)

boolean

d)

int

16.

Which data type stores memory address of an object?

a)

Primitive

b)

Non-Primitive

c)

boolean

d)

char

17.

Which of the following can store multiple values of same type?

a)

Variable

b)

Method

c)

Array

d)

Class

18.

Which feature of Java handles runtime errors?

a)

Inheritance

b)

Compilation

c)

Exception Handling

d)

Polymorphism

19.

Which of the following is TRUE about primitive data types?

a)

They store object references

b)

They are slower

c)

They can be null

d)

They store actual values

20.

Which JVM component improves performance?

a)

Compiler

b)

Interpreter

c)

JIT Compiler

d)

Loader