MCQs on Control Structures | Visual Basic .NET (VB.NET)

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)

  1. What keyword is used to begin an If statement in VB.NET?
    a) Begin
    b) If
    c) Then
    d) Else
  2. In VB.NET, the ElseIf keyword is used for:
    a) Looping
    b) Nested loops
    c) Multiple conditional checks
    d) Termination
  3. 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
  4. 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
  5. Which keyword is required to end a Select Case block in VB.NET?
    a) End Select
    b) End Case
    c) Break
    d) Return
  6. Can If statements in VB.NET be nested within each other?
    a) Yes
    b) No
  7. 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)

  1. What is the keyword to start a For loop in VB.NET?
    a) Repeat
    b) For
    c) Loop
    d) Iterate
  2. 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
  3. 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
  4. 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.
  5. How do you exit a For loop prematurely?
    a) Break
    b) Exit For
    c) Terminate
    d) GoTo
  6. Which keyword is used to continue the next iteration of a While loop?
    a) Next
    b) Continue While
    c) Exit While
    d) Break
  7. 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.
  8. 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

  1. 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
  2. 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
  3. Is it considered good practice to use GoTo in modern VB.NET programming?
    a) Yes, always
    b) No, it should be avoided unless necessary
  4. Which keyword is used to exit from a Do While loop in VB.NET?
    a) Break
    b) Exit While
    c) Exit Do
    d) Terminate
  5. Can the GoTo statement jump outside of a loop in VB.NET?
    a) Yes
    b) No
  6. 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
  7. Can the Exit statement be used outside of loops or procedures?
    a) Yes
    b) No
  8. 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.
  9. 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.
  10. Can a GoTo statement be used within a Select Case structure?
    a) Yes
    b) No
  11. Is it possible to use both GoTo and Exit in the same procedure?
    a) Yes
    b) No
  12. 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.
  13. 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.
  14. 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.
  15. 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

Answer Key

QnoAnswer (Option with Text)
1b) If
2c) Multiple conditional checks
3c) Select Case
4b) Executes the first true condition
5a) End Select
6a) Yes
7d) All of the above
8b) For
9b) Executes while the condition is true
10b) Specifies increment/decrement values
11a) It executes at least once
12b) Exit For
13b) Continue While
14a) Yes, if the condition is always true
15a) Defaults to Step 1
16b) To jump to a labeled statement
17a) Precede it with a colon
18b) No, it should be avoided unless necessary
19c) Exit Do
20a) Yes
21b) A compile-time error occurs
22b) No
23a) The procedure terminates immediately.
24b) It immediately terminates the loop.
25a) Yes
26a) Yes
27c) Both a and b.
28a) It’s difficult to read and debug code.
29b) It exits a procedure immediately.
30b) To jump to a labeled point in the code

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top