wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Break the fear

Total questions: 10

Worksheet time: 10mins

Name
Class
Date
1.

public class TestWhile {

public static void main(String[] args)

{

int i = 1;

int j = 20;

int k = 31;

while (i < j) {

k += (i * j);

i = i * 2;

j--;

}

System.out.println("i = " + i + " j = " + j + " k = " + k);

}

}

a)

i = 15 j = 13 k = 759

b)

i = 16 j = 16 k = 297

c)

i = 11 j = 10 k = 801

d)

i = 15 j = 13 k = 808

2.

public class GotIt

{

public static void main(String[] argss)

{

int m = 0;

while (m++ < 2)

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

}

}

a)

0 1 2

b)

1 2

c)

2

d)

1

3.

public class HarmonicSeries

{

public static void main(String args[])

{

int num = 5;

double result = 0.0;

while (num > 0)

{

result = result + (double) 1 / num;

num--;

}

System.out.println(result);

}

}

a)

2.2833

b)

1.8

c)

0

d)

1.0

4.

public class A {

public static void main(String[] args)

{

System.out.println('j' + 'a' + 'v' + 'a');

}

}

What will be the output of the above code?

(a)  

5.

public class Demo{

public static void main(String[] arr){

Integer num1 = 100;

Integer num2 = 100;

Integer num3 = 500;

Integer num4 = 500;


if(num1==num2){

System.out.print("num1 == num2");

}

else{

System.out.print("num1 != num2");

}

if(num3 == num4){

System.out.print("num3 == num4");

}

else{

System.out.print("num3 != num4");

}

}

}


Above code will give (a)   output.

6.

class Input_Output

{

public static void main(String args[]) throws IOException {

char c;

BufferedReader obj = new BufferedReader(new InputStreamReader(System.in));

do

{

c = (char) obj.read();

System.out.print(c);

} while(c != 'q');

}

}


What will be the output of the following Java program if input given is ‘abcqfghqbcd’?

(a)  

7.

(a)   is used to perform all input and output operations in Java.

8.

Select the correct classes that fall under the checked exception category:

a)

ArithmeticException

b)

FileNotFoundException

c)

IllegalArgumentException

d)

IOException

9.

For any program to design, the following are important steps:

a)

Algorithm

b)

VDT table

c)

Data flow diagram

d)

Coding

10.

In a good algorithm, we see the following features:

a)

Precise

b)

Clear IO operation

c)

Finite

d)

Grammatically correct