You are on page 1of 5
Visual Basic Questions and Answers - Single- Alternative and Dual-Alternative Selection Structures «Prev Next This set of Visual Basic Multiple Choice Questions & Answers (MCQs) focuses on “Single-Alternative ant Dual-Alternative Selection Structures” 1. In Visual Basic is used for coding single-alternative and dual-alternative selectio: structures. a) If..Then...Else statement b) Switch-Case block ¢) Recursion d) function overloading View Answer Answer: a 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 statemen block where the condition may be true and another if the condition is false. advertisement 2.The keyword is necessary only in a dual-alternative selection structure. a) Alternative b) Next, d) Else View Answer Answer: d 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 secon« alternative in the dual-alternativeselection structure. 3. The condition must be a expression a) Integer b) Double @ Boolean d) Short View Answer Answer: c Explanation: the condition of If..Then...£lse statement has to be a Boolean. The condition of the If. Then...£lse statements evaluate to either True or False and depending on that the respective block o code is executed. 4, The set of statements contained in each path is referred to as a a) Condition block b) Statement block ©) Path block d) IfElse block View Answer Answer: b Explanation: The code blocks under the If...Then...Else statements are called statement block. On: executes if the condition is true and the other if itis false. 5, What is wrong with the following if-else structure? Join Sanfoundry@YouTube If intQuantity > 5 Then ablDiscountRate = .1 Else ab1DiscountRate = .@5 End If a) No error b) Conditions not in brackets ©) No ; after statements d) Then’ should have been ‘then’ View Answer Answer: a Explanation: The syntax of the If...hen...Else statement block is, Tf condition Then statenent block to be processed when the condition is true Else statenent block to be processed when the condition is false End If 6. Comparison operators are also termed as a) Comparators b) Comparables ©) Relations d) Relational operators View Answer Answer: d 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 t another value. advertisement 7. What is the comparison operator to find if two values are equal? a) equalsto b)= ©) EqualsTo d) Equals View Answer Answer: b 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 0) False d) True View Answer Answer: ¢ Explanation: Comparison operators are evaluated after any arithmetic expressions. Thus the firs 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 0) False d) True View Answer Answer: d Explanation: Comparison operators are evaluated after any arithmetic expressions. In the abow: syntax, the first expression is greater than second, thus it returns true. 10. What is the result of the expression 10-2420 ><2*25-2? a) Syntax error b) No resulting value found ©) False d) True View Answer Answer: a Explanation: Comparison operators are evaluated after any arithmetic expressions. Here >< is no any sort of operator. Thus we will get a syntax error, when we evaluate the above expression

You might also like