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

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
   D.) function overloading

Answer: Option 'A'

 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.

DigitalOcean Referral Badge

2.

The __________ keyword is necessary only in a dual-alternative selection structure.

   A.) Else
   B.) Next
   C.) Alternative
   D.) Dual

Answer: Option 'A'

Else

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.

DigitalOcean Referral Badge

3.

The condition must be a __________ expression.

   A.) Integer
   B.) Double
   C.) Boolean
   D.) Short

Answer: Option 'C'

Boolean

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.

DigitalOcean Referral Badge

4.

What is wrong with the following if-else structure?

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

   A.) No error
   B.) No ; after statements
   C.) ‘Then’ should have been ‘then’
   D.) Conditions not in brackets

Answer: Option 'A'

No error

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

DigitalOcean Referral Badge

5.

The set of statements contained in each path is referred to as a __________

   A.) Condition block
   B.) Statement block
   C.) IfElse block
   D.) Path block

Answer: Option 'B'

Statement block

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.

DigitalOcean Referral Badge

6.

Comparison operators are also termed as __________

   A.) Comparators
   B.) Relational operators
   C.) Comparables
   D.) Relations

Answer: Option 'B'

Relational operators

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.

DigitalOcean Referral Badge

7.

What is the comparison operator to find if two values are equal?

   A.) equalsto
   B.) =
   C.) Equals
   D.) EqualsTo

Answer: Option 'B'

=

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

DigitalOcean Referral Badge

8.

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

Answer: Option 'D'

True

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

DigitalOcean Referral Badge

9.

What is the result of the expression 10-5>3*4-2?

   A.) Syntax error
   B.) No resulting value found
   C.) False
   D.) True

Answer: Option 'C'

False

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

DigitalOcean Referral Badge

10.

What is the result of the expression 10-2+20 ><2*25-2?

   A.) Syntax error
   B.) False
   C.) True
   D.) No resulting value found

Answer: Option 'A'

Syntax error

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.

DigitalOcean Referral Badge

Single-Alternative and Dual-Alternative Selection Structures - Visual Basic Questions and Answers Download Pdf

Recent Posts