wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Quiz I- B

Total questions: 31

Worksheet time: 10mins

Name
Class
Date
1.

What is the correct syntax to output "HelloWorld" in Java?

(a)  

2.

JVM stands for

a)

Java Vital Machine

b)

Java Virtual Machine

c)

Java Vendor machine

3.

Java programs ________________

a)

are only compiled

b)

are only compiled not interpreted

c)

are only interpreted

d)

are both compiled and interpreted

4.

In Java, execution starts from ___________ function.

a)

get()

b)

main()

c)

java()

d)

display()

5.

Java is

a)

platform dependent

b)

platform indeprndent

6.

Java is a

a)

Procedure Oriented Language

b)

Structure Oriented Language

c)

Object_Oriented Language

d)

Machine Language

7.

JDK stands for

a)

Java Developer Kit

b)

Java Development Kit

c)

Java Design Kit

d)

Java Debugging Kit

8.

Java was developed by

a)

James gosling

b)

John gosling

c)

James frank

d)

John frank

9.
What are the legal indexes for the array ar, given the following declaration:
int[] ar = {2, 4, 6, 8 }
a)
 0, 1, 2, 3
b)
 1, 2, 3, 4
c)
2, 4, 6, 8
d)
 0, 2, 4, 6
10.

What is the first index of an array?

a)

1

b)

0

c)

2

d)

3

11.

What would the new value of A be?

A=1;

a++;

a)

1

b)

2

c)

3

d)

4

12.

What's the value of below?


int i=5;

System.out.println(i++);

System.out.println(i);

System.out.println(++i);

a)

5

6

7

b)

6

6

7

c)

6

7

8

d)

5

5

6

13.

Find the output of the following snippet.


class Numbers

{

public static void main(String args[])

{

int a=20, b=10;

if((a<b)&&(b++ <25))

{

System.out.println("this is any language logic");

}

System.out.println(b);

}

}

a)

10

b)

12

c)

11

d)

Compilation Error

14.

Below are conditional statements in Java, except:

a)

if

b)

switch

c)

else

d)

if else

15.

Which of the condition below that is just the same with the output program.

Print "Hello World" if x is greater than y.

a)

x>y

b)

y<x

c)

y>x

d)

x<y

16.

A while loop has the following format:

a)

while (condition)

{

...

}

b)

while

{

...

}

c)

continue while (condition)

{

...

}

d)

while [condition]

[

...;

]

17.

OUTPUT?

int i = 1;

while (i < 5) {

System.out.println("Hello");

i++;

}

a)

Hello

Hello

Hello

Hello

Hello

b)

Hello

Hello

Hello

Hello

c)

Hello

Hello

Hello

d)

Hello

18.

How many stars are printed?

a)

7

b)

3

c)

4

d)

5

e)

Infinite Loop

19.

In total, how many times is the inner loop executed?

a)

5

b)

10

c)

15

d)

50

e)

Infinite Loop

20.

How many times does the loop print a *

a)

40

b)

20

c)

24

d)

30

e)

Infinite Loop

21.

What does the following code print?

a)

A rectangle of 8 rows with 5 stars per row

b)

A rectangle of 8 rows with 4 stars per row

c)

A rectangle of 6 rows with 5 stars per row

d)

A rectangle of 6 rows with 4 stars per row

e)

Infinite Looo

22.

What does the following code print?

a)

A rectangle of 9 rows with 5 stars per row

b)

A rectangle of 6 rows with 6 stars per row

c)

A rectangle of 7 rows with 5 stars per row

d)

A rectangle of 7 rows with 6 stars per row

e)

Infinite Loop

23.

How many times does the following method print a *?

a)

9

b)

6

c)

7

d)

10

24.
a)

10

b)

15

c)

17

d)

22

e)

25

25.
How many times will the following code print "Welcome to Java"?
int count = 0;
while (count < 10) {
 System.out.println("Welcome to Java");
 count++;
}
a)
8
b)
9
c)
10
d)
0
26.

Predict the output?

public class Main {

public static void main(String args[]) {

int arr[] = {10, 20, 30, 40, 50};

for(int i=0; i < arr.length; i++)

{

System.out.print(" " + arr[i]);

}

}

}

a)

10 20 30 40 50

b)

Compiler Error

c)

10 20 30 40

27.

class Test {

public static void main(String args[]) {

int arr[2];

System.out.println(arr[0]);

System.out.println(arr[1]);

}

}

a)

0

0

b)

garbage value

garbage value

c)

Compiler Error

d)

Exception

28.

what is the output of this question?

class Test1 {

public

static void main(String[] args)

{

int x = 20;

System.out.println(x);

}

static

{

int x = 10;

System.out.print(x + " ");

}

}

a)

10 20

b)

20 10

c)

10 10

d)

20 20

29.
what is the name of java before it was renamed?
a)
Oak
b)
javas
c)
hava
d)
kava
30.

Polymorphism related to :

a)

PPO

b)

Class

c)

OPP

d)

OOP

31.

Which one is correct?

a)

public static main(Strings[] args) { }

b)

public private static main(Strings[] args) { }

c)

public static void main(Strings[] args) { }

d)

public void static main(Strings[] args) { }