This set of Visual Basic Multiple Choice Questions & Answers (MCQs) focuses on “Nested Selection Structures”.
1. When a selection structure’s true part or false part contains another selection structure, the inner selection structured is referred to as __________
a) Implicit selection structure
b) Inner selection structure
c) Outer selection structure
d) Nested selection structure
View Answer
Explanation: Both parts in a selection structure can include another selection structure. When a selection structure’s true part or false part contains another selection structure, the inner selection structured is referred to as a nested selection structure because it is contained within the outer selection structure.
2. Most common error that occur in selection structure is __________
a) Logical error
b) Syntactical error
c) Segmentation fault
d) Compiler error
View Answer
Explanation: Most common error that occurs in selection structure is logical errors. Logic errors in selection structures are a result of one of the following three mistakes: using a compound condition rather than a nested selection structure; reversing the primary and secondary decisions; or using an unnecessary nested selection structure.
3. __________ refers to the process of checking your algorithm while seated at your desk.
a) Disk-checking
b) Desk-checking
c) Drive-checking
d) Paper-checking
View Answer
Explanation: Desk-checking refers to the process of reviewing the algorithm while seated at your desk rather than in front of the computer. Desk-checking is also called hand-tracing, because you use a pencil and paper to follow each of the algorithm’s instructions by hand.
4. What will be the content of num, after the code execution; if before code execution num has value 90?
If num<=100 num=num*2; ElseIf num>500 Num=num*3; Endif
a) 0
b) 90
c) 180
d) 270
View Answer
Explanation: Since at first, num=90, i.e. it is less than 100, so it enters if and increase num by num*2; thus value of num after code execution becomes 180.
5. What will be the content of num, after code execution; if before code execution num has value 1000?
If num<=100 num=num*2; ElseIf num>500 Num=num*3; Endif
a) 0
b) 1000
c) 3000
d) 2000
View Answer
Explanation: Since at first, num=1000, i.e. it is greater than 500, so it enters elseif and increase num by num*3; thus value of num after code execution becomes 3000.
6. What will be the content of num, after code execution; if before code execution num has value 200?
If num<=100 num=num*2; ElseIf num>500 Num=num*3; Endif
a) 0
b) 200
c) 400
d) 600
View Answer
Explanation: Since at first, num=200, i.e. num is neither less than or equal to 100 nor it is greater than 500, so it does not enter anywhere, thus value of num does not change, thus it remains 200.
7. What will be the content of Text after the code is executed with id=2?
If id==1 Then Text=”Janet”; Elseif id==2 OrElse id==3 Then Text=”Mark” ElseIF id==4 Then Text=”Jerry” Else Text=”Sue “; EndIf
a) Janet
b) Mark
c) Jerry
d) Sue
View Answer
Explanation: In case of OrElse, if any one of the condition is true, it returns true, thus when in the first Else if statement, we find id =2, and there is OrElse, so it does not go to the condition id==3, before that it returns true. Thus it enters the Else if part and makes the value of text as Mark.
8. What will be the content of Text after the code is executed with id=4?
If id==1 Then Text=”Janet”; Elseif id==2 OrElse id==3 Then Text=”Mark” ElseIF id==4 Then Text=”Jerry” Else Text=”Sue “; EndIf
a) Janet
b) Mark
c) Jerry
d) Sue
View Answer
Explanation: The value of text after the execution of the code will be jerry. Since id=4 is in the second Else If statement, it returns true, thus the value of text becomes jerry.
9. What will be the content of Text after the code is executed with id=8?
If id==1 Then Text=”Janet”; Elseif id==2 OrElse id==3 Then Text=”Mark” ElseIF id==4 Then Text=”Jerry” Else Text=”Sue “; EndIf
a) Janet
b) Mark
c) Jerry
d) Sue
View Answer
Explanation: The value of text after the execution of the code will be Sue. Since id=8 is not satisfied that is it is not found in any of the If or Else if statements, thus it enters the Else statement and makes the value of Text as Sue.
10. A nested selection structure can be contained in ____________________ of another selected structure.
a) Only in the truth part
b) Only in the false part
c) Either in truth or in false part
d) Both in truth and in false part
View Answer
Explanation: A nested selection structure can be contained in both in truth and false part of another selection structure. For example, we can have the following:
If(condition) { If(condition) Statement; Else Statement; } Else { If(Condition) Statement; Else Statement; }
Sanfoundry Global Education & Learning Series – Visual Basic.
To practice all areas of Visual Basic, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Practice Computer Science MCQs
- Buy Computer Science Books
- Apply for Computer Science Internship
- Buy Visual Basic Books
- Apply for Visual Basic Internship