31. What is the purpose of the for loop in Java?

  • To perform arithmetic operations.
  • To perform conditional branching.
  • To iterate over a collection of elements a specific number of times.
  • To declare variables.

32. What is the purpose of the while loop in Java?

  • To perform arithmetic operations.
  • To perform conditional branching.
  • To iterate over a collection of elements as long as a condition is true.
  • To declare variables.

33. What is the purpose of the for-each loop in Java?

  • To perform arithmetic operations.
  • To perform conditional branching.
  • To iterate over elements of an array or a collection.
  • To declare variables.

34. What is the purpose of the break statement in Java?

  • To terminate the program execution.
  • To skip the current iteration of a loop and move to the next iteration.
  • To exit a loop or switch statement before its normal completion.
  • To resume execution after the end of a loop.

35. What is the purpose of the continue statement in Java?

  • To terminate the program execution.
  • To skip the current iteration of a loop and move to the next iteration.
  • To exit a loop or switch statement before its normal completion.
  • To resume execution after the end of a loop.

Leave a Reply