# Visual Basic Questions and Answers – Single-Alternative and Dual-Alternative Selection Structures

«
»

This set of Visual Basic Multiple Choice Questions & Answers (MCQs) focuses on “Single-Alternative and Dual-Alternative Selection Structures”.

1. In Visual Basic __________ is used for coding single-alternative and dual-alternative selection structures.
a) If…Then…Else statement
b) Switch-Case block
c) Recursion

Explanation: In Visual Basic If…Then…Else statement is used for coding single-alternative and dual-alternative selection structures. The If…Then…Else statement statements provide for a statement block where the condition may be true and another if the condition is false.

2. The __________ keyword is necessary only in a dual-alternative selection structure.
a) Alternative
b) Next
c) Dual
d) Else

Explanation: The Else keyword is necessary in dual-alternative selection structure. The Else part of the If…Then…Else statement evaluates the condition where the condition is false. So, it is the second alternative in the dual-alternativeselection structure.

3. The condition must be a __________ expression.
a) Integer
b) Double
c) Boolean
d) Short

Explanation: the condition of If…Then…Else statement has to be a Boolean. The condition of the If…Then…Else statements evaluate to either True or False and depending on that the respective block of code is executed.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

4. The set of statements contained in each path is referred to as a __________
a) Condition block
b) Statement block
c) Path block
d) IfElse block

Explanation: The code blocks under the If…Then…Else statements are called statement block. One executes if the condition is true and the other if it is false.

5. What is wrong with the following if-else structure?

```If intQuantity > 5 Then
dblDiscountRate = .1
Else
dblDiscountRate = .05
End If```

a) No error
b) Conditions not in brackets
c) No ; after statements
d) ‘Then’ should have been ‘then’

Explanation: The syntax of the If…Then…Else statement block is,

```If condition Then
statement block to be processed when the condition is true
Else
statement block to be processed when the condition is false
End If```

6. Comparison operators are also termed as __________
a) Comparators
b) Comparables
c) Relations
d) Relational operators

Explanation: Comparison operators evaluate the equality or difference in degree of two given values. This means they tell us how one value is related to another, i.e. if one value is greater or not to another value.

7. What is the comparison operator to find if two values are equal?
a) equalsto
b) =
c) EqualsTo
d) Equals

Explanation:Comparison operators evaluate the equality or difference in degree of two given values. The = operator tells if one value is equal to another.

8. What is the result of the expression 10-5>3*4-2?
a) Syntax error
b) No resulting value found
c) False
d) True

Explanation: Comparison operators are evaluated after any arithmetic expressions. Thus the first sub-condition is not greater than the second, thus it will return false.

9. What is the result of the expression 10-2+20>2*14-2?
a) Syntax error
b) No resulting value found
c) False
d) True

Explanation: Comparison operators are evaluated after any arithmetic expressions. In the above syntax, the first expression is greater than second, thus it returns true.

10. What is the result of the expression 10-2+20 ><2*25-2?
a) Syntax error
b) No resulting value found
c) False
d) True

Explanation: Comparison operators are evaluated after any arithmetic expressions. Here >< is not any sort of operator. Thus we will get a syntax error, when we evaluate the above expression.

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. 