wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

B23CBT304 - WEB APPLICATION DEVELOPMENT UNIT - IV

Total questions: 10

Worksheet time: 3hrs 52mins

Name
Class
Date
1.

Which of these selection statements test only for equality?

a)

if

b)

switch

c)

if & switch

d)

none of the mentioned

2.

Which of these are selection statements in Java?

a)

if()

b)

for()

c)

continue

d)

break

3.

Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?

a)

do-while

b)

while

c)

for

d)

none of the mentioned

4.

Which of these jump statements can skip processing the remainder of the code in its body for a particular iteration?

a)

break

b)

return

c)

exit

d)

continue

5.

Which of this statement is incorrect?

a)

switch statement is more efficient than a set of nested ifs

b)

two case constants in the same switch can have identical values

c)

switch statement can only test for equality, whereas if statement can evaluate any type of boolean expression

d)

it is possible to create a nested switch statements

6.

What will be the output of the following Java program?

  1. class selection_statements

  2. {

  3. public static void main(String args[])

  4. {

  5. int var1 = 5;

  6. int var2 = 6;

  7. if ((var2 = 1) == var1)

  8. System.out.print(var2);

  9. else

  10. System.out.print(++var2);

  11. }

  12. }

a)

1

b)

2

c)

3

d)

4

7.

What will be the output of the following Java program?

  1. class comma_operator

  2. {

  3. public static void main(String args[])

  4. {

  5. int sum = 0;

  6. for (int i = 0, j = 0; i < 5 & j < 5; ++i, j = i + 1)

  7. sum += i;

  8. System.out.println(sum);

  9. }

  10. }

a)

5

b)

6

c)

14

d)

Compilation Error

8.

What will be the output of the following Java program?

  1. class jump_statments

  2. {

  3. public static void main(String args[])

  4. {

  5. int x = 2;

  6. int y = 0;

  7. for ( ; y < 10; ++y)

  8. {

  9. if (y % x == 0)

  10. continue;

  11. else if (y == 8)

  12. break;

  13. else

  14. System.out.print(y + " ");

  15. }

  16. }

  17. }

a)

1 3 5 7

b)

2 4 6 8

c)

1 3 5 7 9

d)

1 2 3 4 5 6 7 8 9

9.

What will be the output of the following Java program?

  1. class Output

  2. {

  3. public static void main(String args[])

  4. {

  5. final int a=10,b=20;

  6. while(a<b)

  7. {

  8.  

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

  10. }

  11. System.out.println("World");

  12.  

  13. }

  14. }

a)

Hello

b)

run time error

c)

Hello world

d)

compile time error

10.

What will be the output of the following Java program?

  1. class Output

  2. {

  3. public static void main(String args[])

  4. {

  5. int a = 5;

  6. int b = 10;

  7. first:

  8. {

  9. second:

  10. {

  11. third:

  12. {

  13. if (a == b >> 1)

  14. break second;

  15. }

  16. System.out.println(a);

  17. }

  18. System.out.println(b);

  19. }

  20. }

  21. }

a)

5 10

b)

10 5

c)

5

d)

10