Show
NINJA FUN FACT Coding will soon be as important as reading
35 Questions 35 Marks 25 Mins
The correct answer is If-Else. Key Points
Additional Information
Important Points
India’s #1 Learning Platform Start Complete Exam Preparation
Daily Live MasterClasses
Practice Question Bank
Mock Tests & Quizzes Trusted by 3.4 Crore+ Students
for(int i=1; i<5; i++)
{ System.out.print(i +",");
}
A.1,2,3,4, 2. for is ______________ statement in java.A.branchingB.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-statementB.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, 13. An enhanced FOR loop work with only Collection type data. Examples of Collection are ___.A.Array Class type or any regular array variableB.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 continueB.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?
a) 1 2 b) 2 3 c) 1 3 d) 3 View Answer Answer: d 2. The while loop repeats a set of code while the condition is not met? a) True b) False View Answer Answer: b 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
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 5. Which of the following is used with the switch statement? a) Continue b) Exit c) break d) do View Answer Answer: c 6. What is the valid data type for variable “a” to print “Hello World”?
a) int and float b) byte and short c) char and long d) byte and char View Answer Answer: d 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 8. Which of the following is not a valid jump statement? a) break b) goto c) continue d) return View Answer Answer: b 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 10. Which of the following is not a valid flow control statement? a) exit() b) break c) continue d) return View Answer Answer: a 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. Next Steps:
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. |