Advertisement
WaseemAlkurdi

Untitled

Jul 31st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. Private Sub cmdCall_Click()
  2. Dim b As Integer
  3. a = 10
  4. b = 15
  5. Print a; b;
  6. Call mySub(a, b)
  7. Print a; b
  8. End Sub
  9. Private Sub mySub(x As Integer, y As Integer)
  10. x = 11
  11. y = 16
  12. End Sub
  13.  
  14. What is the output of the following program?
  15.  
  16. a. 10 15 11 16
  17. b. 10 15 10 15
  18. c. Syntax error
  19. d. None of the above
  20.  
  21. Answer: c
  22. Explanation: The first argument is of data type Variant while the type of first parameter is Integer.
  23.  
  24. Private Sub cmdCall_Click()
  25. Dim a As Integer
  26. Dim b As Integer
  27. a = 10
  28. b = 15
  29. Print a; b;
  30. Call mySub(a, b)
  31. Print a; b
  32. End Sub
  33. Private Sub mySub(x As Single, y As Integer)
  34. x = 11
  35. y = 16
  36. End Sub
  37.  
  38. What is the output of the following program?
  39.  
  40. a. 10 15 11 16
  41. b. 10 15 11 16
  42. c. Syntax error
  43. d. None of the above
  44.  
  45. Answer: c
  46. Explanation: We told mySub to take x by reference, and as a Single, but when we called it, we passed an Integer.
  47.  
  48. Private Sub cmdCall_Click()
  49. Dim a As Integer
  50. Dim b As Integer
  51. a = 10
  52. b = 15
  53. Print a; b;
  54. Call mySub((a), b)
  55. Print a; b
  56. End Sub
  57. Private Sub mySub(x As Integer, y As Integer)
  58. x = 11
  59. y = 16
  60. End Sub
  61.  
  62. What is the output of the following program?
  63.  
  64. a. 10 15 11 16
  65. b. 10 15 10 16
  66. c. 10 15 10 15
  67. d. Syntax error
  68.  
  69. Answer: b
  70. The variable is overriden and passed by value (using an extra pair of brackets).
  71.  
  72. Private Sub cmdCall_Click()
  73. Dim a As Integer
  74. Dim b As Integer
  75. a = 10
  76. b = 15
  77. Print a; b;
  78. Call mySub(a , a)
  79. Print a; b
  80. End Sub
  81. Private Sub mySub(x As Integer, y As Integer)
  82. x = 11
  83. y = 16
  84. End Sub
  85.  
  86. What is the output of the following program?
  87.  
  88. a. 10 15 11 16
  89. b. 10 15 16 16
  90. c. 10 15 16 15
  91. d. Syntax error
  92.  
  93. Answer: c
  94. The variable a is passed twice, so it now has two memory locations.
  95.  
  96. 4. How many asterisks will be printed after clinking on Command1?
  97. Private Sub Command1_Click()
  98. Dim a As Integer
  99. a = 1
  100. Do While (a <= 4)
  101. Call Mysub
  102. a = a + 1
  103. Loop
  104. End Sub
  105. Private Sub Mysub()
  106. Print "**" ;
  107. End Sub
  108.  
  109. a. 4
  110. b. 6
  111. c. 8
  112. d. 10
  113.  
  114. Answer: c
  115.  
  116. 6. What is the output of the following block of code?
  117. Private Sub cmdDisplay_Click()
  118. Dim x As Integer, j As Integer
  119. j = 0
  120. For j = 2 To 4
  121. Call Add1(j)
  122. x = x + j
  123. Next j
  124. Print x
  125. End Sub
  126. Private Sub Add1(num As Integer)
  127. num = num + 1
  128. End Sub
  129.  
  130. a. 8
  131. b. 9
  132. c. 6
  133. d. 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement