wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java Basic Day-2

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

which of the following is a legal identifier in java?

a)

2variable

b)

#myvar

c)

+@$var

d)

$_myvar

2.

which of these is NOT a valid keyword or reserved word in java?

a)

default

b)

null

c)

String

d)

volatile

3.

which is the legal range of values fro a short?

a)

-128 to +127

b)

-255 to 255

c)

-32768 to 32767

d)

0 to 65535

4.

which declaration of the main() method is valid?

a)

public void main(String args[])

b)

public void static main(String args[])

c)

final public static void main(String []arr)

d)

public static void main(String []arr)

5.

Is 3*4 equivalent to 3 << 2 ?

a)

Yes

b)

NO

6.

what will be the output?

public class Test

{

public static void main(String[] args) {

double d=100.04;

float f=d;

System.out.println(""+f);

}

}

a)

100.04

b)

100.0

c)

100

d)

Compilation Error

7.

Which Operator will always evaluate all the operands ?

a)

||

b)

&&

c)

?:

d)

%

8.

Which of these is long data type literal?

a)

0x99fffL

b)

ABCDEFG

c)

0x99fffa

d)

99671246

9.

Which of these can not be used for a variable name in Java?

a)

identifier

b)

keyword

c)

identifier & keyword

d)

none of the mentioned

10.

What will be the error in the following Java code?

byte b = 50;

b = b * 50;

a)

b cannot contain value 100, limited by its range

b)

* operator has converted b * 50 into int, which can not be converted to byte without casting

c)

b cannot contain value 50

d)

No error in this code