wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Programming Quiz

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is the return type of a constructor in Java[ ]

a)

int

b)

void

c)

No return type

d)

Object

2.

Java is a ______________ language.[ ]

a)

Platform dependent

b)

Platform Independent

c)

Machine

d)

none

3.

How many bytes are occupied by float data type in java[ ]

a)

2 bytes

b)

4 bytes

c)

8 bytes

d)

4 bits

4.

Return type _________ indicates that a method will not return a value.[ ]

a)

int

b)

double

c)

void

d)

Boolean

5.

Methods that perform common tasks and do not require objects are called ______methods.[ ]

a)

final

b)

non-static

c)

dynamic

d)

static

6.

If a=5, then what is the value of result, if result = a++ + ++a + --a - a--;[ ]

a)

13

b)

18

c)

11

d)

12

7.

If a=8, then what is the value of x and y x=a>>2 y=a<<2;[ ]

a)

x=2 y=2

b)

x=2 y=32

c)

x=32 y=2

d)

x=32 y=32

8.

If one or both operands is a floating-point value, we get a ____________ type result[ ]

a)

int

b)

float

c)

boolean

d)

char

9.

Java applications begin execution at method ___________.[ ]

a)

public static void main()

b)

public final void main()

c)

private static void main()

d)

public static int main()

10.

Which of the following is a method having same name as that of its class?[ ]

a)

final

b)

static

c)

class

d)

constructor

11.

What is the output of the following code? System.out.println(5 + "5");[ ]

a)

10

b)

55

c)

Compilation Error

d)

Runtime Error

12.

_________keeps together code and the data it manipulates and keeps both safe from outside interference.[ ]

a)

Encapsulation

b)

Abstraction

c)

Polymorphism

d)

Inheritance

13.

this() is used for ____________________[ ]

a)

call the method

b)

call the Constructor

c)

call the object

d)

none

14.

Variables defined inside methods, constructors or blocks are called ________variables[ ]

a)

class

b)

instance

c)

local

d)

global

15.

Assigning an int data type to a double data type will be considered as ___________[ ]

a)

Narrowing

b)

Widening

c)

Downcasting

d)

Casting

16.

(a)   is the OOPs concept to create new class by using existing class.

17.

(a)   is the symbol to use Bitwise exclusive OR

18.

Static block is executed before (a)   method.

19.

Keyword (a)   requests memory from the system to store an object.

20.

Java code needs to be compiled into (a)   code before it can be executed.