wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java MCQs Worksheet

Total questions: 50

Worksheet time: 25mins

Name
Class
Date
1.

Java was originally developed by

a)

Microsoft

b)

Sun Microsystems

c)

IBM

d)

Oracle

2.

Java is primarily known as a

a)

Low-level language

b)

Assembly language

c)

Platform-independent language

d)

Machine-dependent language

3.

Which component makes Java platform independent?

a)

JDK

b)

JRE

c)

JVM

d)

JIT

4.

The Java source file extension is

a)

.jav

b)

.class

c)

.java

d)

.exe

5.

The Java compiler converts source code into

a)

Machine code

b)

Bytecode

c)

Assembly code

d)

Object code

6.

Bytecode is executed by

a)

Compiler

b)

Editor

c)

JVM

d)

Loader

7.

The default value of an int instance variable is

a)

null

b)

1

c)

0

d)

Undefined

8.

Which of the following is not a Java feature?

a)

Object-oriented

b)

Secure

c)

Portable

d)

Pointer-based

9.

Which keyword is used to define a constant in Java?

a)

static

b)

constant

c)

final

d)

define

10.

The entry point of a Java program is

a)

start()

b)

init()

c)

main()

d)

run()

11.

Which of the following is a valid main method signature?

a)

public static void main(String args[])

b)

static public int main()

c)

void main(String[])

d)

public void main()

12.

Which operator is used for logical AND?

a)

&

b)

&&

c)

|

d)

||

13.

Which loop executes at least once?

a)

for

b)

while

c)

do-while

d)

foreach

14.

Which control statement is used for multiple branching?

a)

if

b)

if-else

c)

switch

d)

break

15.

Type casting from int to double is

a)

Explicit conversion

b)

Narrowing conversion

c)

Implicit conversion

d)

Invalid

16.

Which data type occupies 8 bytes?

a)

int

b)

float

c)

double

d)

short

17.

Command line arguments are accessed using

a)

Scanner

b)

BufferedReader

c)

args[]

d)

System.in

18.

Which symbol is used to access array elements?

a)

()

b)

{}

c)

<>

d)

[]

19.

Arrays in Java are

a)

Fixed size

b)

Dynamic size

c)

Resizable automatically

d)

Pointer-based

20.

Array index starts from

a)

-1

b)

0

c)

1

d)

Depends on array

21.

Which statement stops loop execution?

a)

continue

b)

break

c)

exit

d)

stop

22.

Which operator is used to compare two values?

a)

=

b)

==

c)

!=

d)

Both B and C

23.

Which of the following is a unary operator?

a)

+

b)

-

c)

++

d)

*

24.

JVM stands for

a)

Java Visual Machine

b)

Java Virtual Machine

c)

Java Verified Machine

d)

Java Variable Machine

25.

Java programs are

a)

Interpreted only

b)

Compiled only

c)

Compiled and interpreted

d)

Assembled

26.

A class in Java is a

a)

Variable

b)

Function

c)

Blueprint of an object

d)

Package

27.

An object is an instance of a

a)

Package

b)

Method

c)

Constructor

d)

Class

28.

Which keyword is used to create an object?

a)

class

b)

object

c)

new

d)

this

29.

A constructor is used to

a)

Destroy objects

b)

Initialize objects

c)

Call methods

d)

Create variables

30.

Constructor name must be same as

a)

Method name

b)

Variable name

c)

Class name

d)

Package name

31.

Constructors do not have

a)

Parameters

b)

Return type

c)

Overloading

d)

Access modifiers

32.

Method overloading is based on

a)

Return type

b)

Method name

c)

Parameter list

d)

Access specifier

33.

Which keyword refers to the current object?

a)

super

b)

static

c)

final

d)

this

34.

Static members belong to

a)

Object

b)

Method

c)

Class

d)

Constructor

35.

Final variable value

a)

Can change

b)

Cannot change

c)

Changes at runtime

d)

Is optional

36.

Which class is immutable?

a)

String

b)

StringBuffer

c)

StringBuilder

d)

StringTokenizer

37.

String objects are stored in

a)

Heap only

b)

Stack

c)

String Constant Pool

d)

Register

38.

Which method compares string content?

a)

==

b)

equals()

c)

compareTo()

d)

Both B and C

39.

StringBuffer is

a)

Immutable

b)

Thread-safe

c)

Non-synchronized

d)

Faster than StringBuilder

40.

StringBuilder is

a)

Thread-safe

b)

Synchronized

c)

Immutable

d)

Non-synchronized

41.

Which class is used to break strings into tokens?

a)

Scanner

b)

Split

c)

StringTokenizer

d)

Token

42.

The default constructor is provided by

a)

Programmer

b)

JVM

c)

Compiler

d)

JRE

43.

Constructor overloading allows

a)

Same name, same parameters

b)

Different name, same parameters

c)

Same name, different parameters

d)

Different return types

44.

Which keyword prevents inheritance?

a)

static

b)

final

c)

private

d)

protected

45.

Which method returns string length?

a)

size()

b)

length()

c)

count()

d)

getLength()

46.

Which operator concatenates strings?

a)

*

b)

&

c)

+

d)

%

47.

Which keyword is used to define a class member shared by all objects?

a)

final

b)

static

c)

this

d)

super

48.

Which of the following is mutable?

a)

String

b)

StringBuilder

c)

Integer

d)

Character

49.

Object creation always involves

a)

Method call

b)

Constructor call

c)

Static block

d)

Final variable

50.

Which class is faster for single-threaded operations?

a)

String

b)

StringBuffer

c)

StringBuilder

d)

StringTokenizer