Boost your programming skills with these 30 MCQs on VB.NET control structures. Perfect for students and professionals, these questions cover conditional statements, loops, and flow-control mechanisms like GoTo and Exit.
Control Structures MCQs
Conditional Statements (If, ElseIf, Select Case)
What keyword is used to begin an If statement in VB.NET? a) Begin b) If c) Then d) Else
In VB.NET, the ElseIf keyword is used for: a) Looping b) Nested loops c) Multiple conditional checks d) Termination
What is the correct syntax for a Select Case statement in VB.NET? a) Switch Case b) Choose Case c) Select Case d) Case Of
How does VB.NET handle multiple ElseIf conditions when they are all true? a) Executes all conditions b) Executes the first true condition c) Executes none d) Throws an error
Which keyword is required to end a Select Case block in VB.NET? a) End Select b) End Case c) Break d) Return
Can If statements in VB.NET be nested within each other? a) Yes b) No
Which operator would you use for combining multiple conditions in an If statement? a) AND/OR b) XOR c) NOT d) All of the above
Looping Structures (For, While, Do While)
What is the keyword to start a For loop in VB.NET? a) Repeat b) For c) Loop d) Iterate
In VB.NET, how does a While loop work? a) Executes until the condition is true b) Executes while the condition is true c) Executes at least once d) Executes until an error occurs
What does the Step keyword do in a For loop? a) Terminates the loop b) Specifies increment/decrement values c) Repeats the loop d) None of the above
Which of the following statements is true about the Do While loop in VB.NET? a) It executes at least once. b) It executes only if the condition is true initially. c) It cannot contain conditions. d) It is the same as a While loop.
How do you exit a For loop prematurely? a) Break b) Exit For c) Terminate d) GoTo
Which keyword is used to continue the next iteration of a While loop? a) Next b) Continue While c) Exit While d) Break
In VB.NET, can a Do While loop run forever? a) Yes, if the condition is always true. b) No, it automatically exits after 10 iterations.
What happens if you omit the Step clause in a For loop? a) Defaults to Step 1 b) Defaults to Step 0 c) Throws an error d) Loop does not execute
Using GoTo and Exit
What is the primary use of the GoTo statement in VB.NET? a) To restart the program b) To jump to a labeled statement c) To terminate the program d) To skip a loop iteration
How do you define a label for the GoTo statement in VB.NET? a) Precede it with a colon b) Enclose it in quotes c) Write it as a comment d) Declare it as a variable
Is it considered good practice to use GoTo in modern VB.NET programming? a) Yes, always b) No, it should be avoided unless necessary
Which keyword is used to exit from a Do While loop in VB.NET? a) Break b) Exit While c) Exit Do d) Terminate
Can the GoTo statement jump outside of a loop in VB.NET? a) Yes b) No
What happens if a GoTo statement refers to a non-existent label? a) The program skips it b) A compile-time error occurs c) It loops back to the beginning d) It crashes at runtime
Can the Exit statement be used outside of loops or procedures? a) Yes b) No
What is the result of using Exit Sub within a procedure? a) The procedure terminates immediately. b) The program terminates. c) Nothing happens. d) It skips the current iteration.
Which statement is true about Exit For? a) It ends the program. b) It immediately terminates the loop. c) It skips the next iteration. d) It does nothing.
Can a GoTo statement be used within a Select Case structure? a) Yes b) No
Is it possible to use both GoTo and Exit in the same procedure? a) Yes b) No
How do you avoid infinite loops while using GoTo? a) Use proper conditions. b) Avoid GoTo entirely. c) Both a and b. d) Use Exit instead.
What’s a major downside of using GoTo in programming? a) It’s difficult to read and debug code. b) It slows down program execution. c) It consumes more memory. d) It limits looping capability.
Which statement best describes Exit Sub in VB.NET? a) It continues the program execution from the start. b) It exits a procedure immediately. c) It skips an error. d) None of the above.
What is the purpose of the GoTo keyword in VB.NET? a) To define a subroutine b) To jump to a labeled point in the code c) To execute loops d) To exit a procedure