wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JAVA: Level-1

Total questions: 15

Worksheet time: 11mins

Name
Class
Date
1.

Choose from below non-mandatory (not MUST) component of a Java Program.

a)

Class name

b)

main method

c)

print method

d)

All of the above

2.

Choose correct signature of main method.

a)

public static int main(String[] args)

b)

private static void main(String[] args)

c)

public static void main(int[] args)

d)

public static void main(String[] args)

3.

In Java Array, index starts from

a)

1

b)

0

c)

-1

d)

-2

4.

What will be output of following code -


public static void main(String[] args) {

System.out.print("Hello");

System.out.println("How are you?");

}

a)

Error

b)

Hello

How are you?

c)

HelloHow are you?

d)

How are you?Hello

5.

In Java, which of the following Loop executes at least once -

a)

for Loop

b)

while Loop

c)

do...while Loop

d)

None of the above

6.

What will be the output of following code -


public static void main(String[] args) {

byte b = 135;

System.out.println(b * 2);

}

a)

135

b)

270

c)

135 * 2

d)

Compilation Error

7.

to assign a value as "2.5", which data type I can use

a)

int

b)

boolean

c)

char

d)

float

8.

what will be the output of following program -


public static void main(String[] args) {

char c = 65;

System.out.println(c);

}

a)

A

b)

65

c)

Compilation Error

d)

c

9.

Which of the following is not a valid comparison operator -

a)

<

b)

>

c)

!=

d)

=

10.

In the following Java program how many times "Hello!" will get printed -


public static void main(String[] args) {

for(int i=0; i <=5; i++) {

System.out.println("Hello!");

}

}

a)

4

b)

5

c)

6

d)

7

11.

Choose which data type is a Java class -

a)

int

b)

long

c)

String

d)

boolean

12.

which statement will help to identify if content of string1 and string2 is exactly the same

a)

string1 == string2

b)

string1.equals(string2)

c)

string1.equalsIgnoreCase(string2)

d)

All of the above

13.

In following program, how many "Hello!" will get printed -


public static void main(String[] args) {

for(int i=6; i <=5; i--) {

System.out.println("Hello!");

}

}

a)

0

b)

1

c)

2

d)

Infinite

14.

In following program, how many "Hello!" will get printed -


public static void main(String[] args) {

int i = 0;

while(i <=5) {

System.out.println("Hello!");

}

}

a)

0

b)

5

c)

6

d)

infinite

15.

What will be the output of following program -


public static void main(String[] args) {

String s1 = new String("Amol");

String s2 = new String("Amol");

System.out.println(s1 == s2);

}

a)

s1 == s2

b)

true

c)

false

d)

compilation error