Which of the following is not a type of iteration statement in java?

Which of the following is not a type of iteration statement in java?

NINJA FUN FACT

Coding will soon be as important as reading

Which of the following is not a type of iteration statement in java?

Which of the following is not a type of iteration statement in java?

Free

35 Questions 35 Marks 25 Mins

The correct answer is If-Else.

Which of the following is not a type of iteration statement in java?
Key Points

  • If-Else is not a type of loop in C.
    • The if-else statement in C is used to perform the operations based on some specific condition.
    • The operations specified in if block are executed if and only if the given condition is true.

Which of the following is not a type of iteration statement in java?

Which of the following is not a type of iteration statement in java?
Additional Information

  • Looping Statements in C execute the sequence of statements many times until the stated condition becomes false.
  • A loop in C consists of two parts, a body of a loop and a control statement.
  • The control statement is a combination of some conditions that direct the body of the loop to execute until the specified condition becomes false.
  • The purpose of the C loop is to repeat the same code a number of times.

Which of the following is not a type of iteration statement in java?
Important Points 

Loop Type Description
While Loop
  • In a while loop, a condition is evaluated before processing a body of the loop. If a condition is true then and only then the body of a loop is executed.
Do-While Loop
  • In a do-while loop, the condition is always executed after the body of a loop. It is also called an exit-controlled loop.
For Loop
  • In a for loop, the initial value is performed only once, then the condition tests and compares the counter to a fixed value after each iteration, stopping them for a loop when false is returned.

India’s #1 Learning Platform

Start Complete Exam Preparation

Which of the following is not a type of iteration statement in java?

Daily Live MasterClasses

Which of the following is not a type of iteration statement in java?

Practice Question Bank

Which of the following is not a type of iteration statement in java?

Mock Tests & Quizzes

Get Started for Free Download App

Trusted by 3.4 Crore+ Students

for(int i=1; i<5; i++) { System.out.print(i +","); } A.1,2,3,4,
B.1,2,3,4
C.1,2,3,4,5
D.none


2. for is ______________ statement in java.

A.branching
B.iteration or looping
C.decision-making
D.all


3. Which statement is Incorrect?

A.for loop must be used when the number of iteration is fixed, it is recommended to use for loop.
B.for loop must be used when the number of iteration is not fixed, it is recommended to use for loop.
C.| for(init;condition;incr/decr){ // code to be executed } | is for loop syntax
D.for loop is a control flow statement that iterates a part of the program multiple times


4. What is not a type of Java for-statement?

A.Simple for-statement
B.for-each statement or extended for-statement
C.for-else statement
D.Labeled for statement


5. Which statements are true about labeled for-statement?

A.We can provide a label to a for-loop to identify uniquely when multiple loops are used in nested formation.
B.Labeling is generally used with break and continue statements.
C.Both A & B
D.Labels are just to decorate for-statements


public static void main(String[] args){ int i = 0; for(i = 100; i >= 0; i -= 10 ){ System.out.print(i + ", "); } } A.100, 90, 80, 70, 60, 50, 40, 20, 10, 0,
B.100, 90, 80, 70, 60, 50, 40, 20, 10,
C.90, 80, 70, 60, 50, 40, 20, 10, 0,
D.None of the above


13. An enhanced FOR loop work with only Collection type data. Examples of Collection are ___.

A.Array Class type or any regular array variable
B.ArrayList
C.HashMap, HashSet
D.ALL


15. A BREAK or CONTINUE statement applies only to the ___ loop.

A.Inner loop or the loop containing break or continue
B.always Outer loop
C.Sometimes inner loop, sometimes outer loop
D.none


This set of Java Multiple Choice Questions & Answers (MCQs) focuses on “Control Statements”.

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

View Answer

Answer: d
Explanation: Since the first if condition is not met, control would not go inside if statement and hence only statement after the entire if block will be executed.

2. The while loop repeats a set of code while the condition is not met? a) True b) False

View Answer

Answer: b
Explanation: While loop repeats a set of code only until the condition is met.

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

View Answer

Answer: b
Explanation: Break halts the execution and forces the control out of the loop.

Check this: Programming Books | BCA MCQs

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

View Answer

Answer: a
Explanation: Do statement checks the condition at the end of the loop. Hence, code gets executed at least once.

5. Which of the following is used with the switch statement? a) Continue b) Exit c) break d) do

View Answer

Answer: c
Explanation: Break is used with a switch statement to shift control out of switch.

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

View Answer

Answer: d
Explanation: The switch condition would only meet if variable “a” is of type byte or char.

7. Which of the following is not a decision making statement? a) if b) if-else c) switch d) do-while

View Answer

Answer: d
Explanation: do-while is an iteration statement. Others are decision making statements.

8. Which of the following is not a valid jump statement? a) break b) goto c) continue d) return

View Answer

Answer: b
Explanation: break, continue and return transfer control to another part of the program and returns back to caller after execution. However, goto is marked as not used in Java.

9. From where break statement causes an exit? a) Only from innermost loop b) Terminates a program c) Only from innermost switch d) From innermost loops or switches

View Answer

Answer: d
Explanation: The break statement causes an exit from innermost loop or switch.

10. Which of the following is not a valid flow control statement? a) exit() b) break c) continue d) return

View Answer

Answer: a
Explanation: exit() is not a flow control statement in Java. exit() terminates the currently running JVM.

Sanfoundry Global Education & Learning Series – Java Programming Language.

To practice all areas of Java language, here is complete set of 1000+ Multiple Choice Questions and Answers.

  • Get Free Certificate of Merit in Java Programming
  • Participate in Java Programming Certification Contest
  • Become a Top Ranker in Java Programming
  • Take Java Programming Tests
  • Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
  • Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Which of the following is not a type of iteration statement in java?

Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.