Search Header Logo

flow control

Authored by PUSHPALATHA C2114

Computers

University

Used 1+ times

flow control
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

1.What would be the output of the following code snippet if variable a=10?

  1. if(a<=0)

  2. {

  3. if(a==0)

  4. {

  5. System.out.println("1 ");

  6. }

  7. else

  8. {

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

  10. }

  11. }

  12. System.out.println("3 ");

a) 1 2

b) 2 3

c) 1 3

d) 3

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

2. What is true about a break?

a) Break stops the execution of entire program

b) Break halts the execution and forces the control out of the loop

c) Break forces the control out of the loop and starts the execution of next iteration

d) Break halts the execution of the loop for certain time frame

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

3.What is true about do statement?

a) do statement executes the code of a loop at least once

b) do statement does not get execute if condition is not matched in the first iteration

c) do statement checks the condition at the beginning of the loop

d) do statement executes the code more than once always

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

4.What is the valid data type for variable “a” to print “Hello World”?


  1. switch(a)

  2. {

  3. System.out.println("Hello World");

  4. }

a) int and float

b) byte and short

c) char and long

d) byte and char

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

5.Which of these are selection statements in Java?

a) if()

b) for()

c) continue

d) break

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

6.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

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

7.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

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?