wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java March

Total questions: 16

Worksheet time: 9mins

Name
Class
Date
1.

What will be the Result if we try to compile and execute this

class Test{

public static void main(String[] ar){

double d=1.2D;

System.out.println(d);

}

}

a)

Compilation Error

b)

1.2

c)

1.2D

d)

d

2.

What is the extension for java?

(a)  

3.

Which of these is the correct way to name a variable?

a)

45632

b)

4variable

c)

player_Name

d)

player name

4.

What does a comment look like in Java?

a)

//comment

b)

#comment

c)

comment

d)

**comment**

5.

Which of these is an input device?

a)

Speaker

b)

Microphone

c)

Monitor

d)

Printer

6.

Which of these is an output device?

a)

Trackpad

b)

Mouse

c)

Monitor

d)

Keyboard

7.

What will the output be from the following code?

int a = 2

System.out.println("Hello" + a + "world!")

a)

Hello Hello world! world!

b)

Hello 2 world!

c)

Hello2world!

d)

Helloaworld!

8.

What is the problem with this code?

Line 1: String myName = "Mary Jacobson";

Line 2: System.out.println ("My name is " + myname);

a)

Line 2: should be System.out.println ("My name is myName");

b)

Line 2: should be System.out.println ("My name is " + myName);

c)

There is no problem with the code

d)

Line 2: should be System.out.display("My name is " + myname);

9.

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

a)

int my Integer= 0;

b)

int int = 0;

c)

int myInteger = 0;

d)

int 1myInteger = 0;

10.

int x = 10;

x = x + 5;

System.out.println(x);

a)

10x

b)

x5

c)

15

d)

5

11.

int sum1 = 100 + 50;

int sum2 = sum1 + 250;

int sum3 = sum2 + sum2;

System.out.println(sum3);

What will be the final output?

a)

sum3

b)

800

c)

950

d)

250

12.

int x = 5;

int y = 6

int z = 50;

System.out.println(x + y + z);

a)

5

b)

61

c)

6

d)

xyz

13.

What is right way of defining String variable?

a)

String name = John;

b)

String name = "John";

c)

String name = "John"

d)

string name = "John";

14.

Which of the following is NOT a data types in java

a)

Boolean

b)

int

c)

java

d)

String

15.

What is at the end of a line of code?

a)

,

b)

;

c)

x

d)

.

16.

When we want to print in Java, we use the code ......

b)

system.out.print();

c)

System.out.println();

d)

System.Out.Printf();