0% found this document useful (0 votes)
84 views20 pages

Mec VB

Visual basic programming language
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views20 pages

Mec VB

Visual basic programming language
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

1. The Visual Basic Code Editor will automatically detect certain types of errors as you are entering code.

A. True

B. False

2. Keywords are also referred to as reserved words.

A. True

B. False

3. The divide-and-conquer-method of problem solving breaks a problem into large, general pieces first,
then refines each piece until the problem is manageable.

A. True

B. False

4. Visual Basic responds to events using which of the following?

A. a code procedure

B. an event procedure

C. a form procedure

D. a property

5.When the user clicks a button, _________ is triggered.

A. an event

B. a method

C. a setting

D. a property

6.What property of controls tells the order they receive the focus when the tab key is pressed during run
time?

A. Focus order
B. Focus number

C. Tab index

D. Control order

7. Sizing Handles make it very easy to resize virtually any control when developing applications with
Visual Basic. When working in the Form Designer, how are these sizing handles displayed?

A. A rectangle with 4 arrows, one in each corner, around your control.

B. A 3-D outline around your control.

C. A rectangle with small squares around your control.

D. None of the above.

8. The Properties window plays an important role in the development of Visual Basic applications. It is
mainly used

A.to change how objects look and feel.

B. when opening programs stored on a hard drive.

C. to allow the developer to graphically design program components.

D. to set program related options like Program Name, Program Location, etc.

9. When creating a new application in Visual Basic, you are asked to supply a name for the program. If
you do not specify a name, a default name is XXXXX XXXXX is this default name?

A. Wapplication followed by a number.

B. Application followed by a number.

C. WindowsApplication.

D. WindowsApplication followed by a number.

10. Which of the properties in a control’s list of properties is used to give the control a meaningful
name?

A. Text

B. ContextMenu

C. ControlName
D. Name

11. Pseudocode is

A. data that have been encoded for security.

B. the incorrect results of a computer program.

C. a program that doesn’t work.

D. the obscure language computer personnel use when speaking.

E. a description of an algorithm similar to a computer language.

12. An algorithm is defined as:

A. a mathematical formula that solves a problem.

B. a tempo for classical music played in a coda.

C. a logical sequence of steps that solve a problem.

D. a tool that designs computer programs and draws the user interface.

13. A variable declared inside an event procedure is said to have local scope

A. True

B. False

14. A variable declared outside of an event procedure is said to have class-level scope.

A. True

B. False

15. Option Explicit requires you to declare every variable before its use.

A. True

B. False

16. The value returned by InputBox is a string.

A. True
B. False

17. What is the correct statement when declaring and assigning the value of 100 to an Integer variable
called numPeople

A. Dim numPeople =

B. Dim numPeople = Int(100)

C. numPeople = 100

D. Dim numPeople As Integer = 100

18. Which of the following arithmetic operations has the highest level of precedence?

A. + –

B. * /

C. ^ exponentiation

D. ( )

19. What value will be assigned to the numeric variable x when the following statement is executed? x =
2+3*4

A. 20

B. 14

C. 92

D. 234

20. Which of the following is a valid name for a variable?

A. Two_One

B. 2One

C. Two One

D. Two.One

21. Keywords in Visual Basic are words that

A. should be used when naming variables.

B. are used to name controls, such as TextBox1, Command2, etc.


C. have special meaning and should not be used when naming variables.

D. are used as prefixes for control names (such as txt, btn, lbl, and lst)

22. To continue a long statement on another line, use:

A. an underscore character.

B. an ampersand character.

C. Ctrl + Enter.

D. a space followed by an underscore character.

23. What is the proper syntax when using a message dialog box?

A. MessageBox.Show(“Hi there”, “Hi”)

B. MessageBox.Show(Hi there, Hi)

C. MessageBox.Show “Hi There”, “Hi”

D. MessageBox.Show Hi There, Hi

24. What will be the output of the following statement? txtBox.Text = FormatCurrency(1234.567)

A. $1234.567

B. 1,234.57

C. $1234.57

D. $1,234.57

25. The following lines of code are correct. If age >= 13 And < 20 Then txtOutput.Text = “You are a
teenager.” End If

A. True

B. False

26. Given that x = 7, y = 2, and z = 4, the following If block will display “TRUE”. If (x > y) Or (y > z) Then
txtBox.Text = “TRUE” End If

A. True

B. False

27. Asc(“A”) is 65. What is Asc(“C”)?

A. 66

B. 67
C. 68

D. “C”

28.Asc(“A”) is 65. What is displayed by txtBox.Text = Chr(65) & “BC”?

A. ABC

B. A BC

C. 656667

D. Not enough information is available.

29. Which of the following expressions has as its value the words “Hello World? surrounded by
quotation marks?

A. “Hello World”

B. Chr(34) & “Hello World”

C. Chr(34) & Hello World & Chr(34)

D. Chr(34) & “Hello World” & Chr(34)

30. Which of the following is true?

A. “Cat” = “cat”

B. “Cat” < “cat”

C. “Cat” > “cat”

D. Relational operators are only valid for numeric values.

31. Which of the following is a valid Visual Basic conditional statement?

A. 2 < n < 5

B. 2 < n Or < 5

C. 2 < n Or 5

D. (2 < n) Or (n < 5)

32. The three main logical operators are ________, _________, and ________.

A. And, Or, Not

B. And, Not, If
C. Or, Not, If

D. False, And, True

33.Which value for x would make the following condition true: x >= 5

A. x is equal to 7

B. x is equal to 5

C. x is equal to 5.001

34. Who developed Visual Basic?

a) Symantec

b) Ashton-Tate

c) Microsoft

d) Sybase

35. Which of the following statement is used to define a class in visual basic?

a) Event class statement

b) Class statement

c) Form class statement

d) Event statement

36. Which of the following extension is used to represent the project file in Visual Basic?

a) .vbp

b) .vb

c) .cls

d) .vvb

37. If you keep a variable undeclared, it is automatically taken as to which of the following data type in
Visual Basic?

a) Char

Int
c) Object

d) String

38. Which of the following applications can be developed using Visual Basic tool?

a) Graphical User Interface

b) Real-time

c) Character User Interface

d) All of the mentioned

39. In Visual Basic, which of the following is used for coding single-alternative and dual-alternative
selection structures?

a) Switch-Case block

b) If…Then…Else statement

c) function overloading

d) Recursion

40. What will be the output of the following Visual Basic code, If the intnumber variable is 110?

If intnumber<=100 Then

Intnumber=intnumber*2;

Else

Intnumber=intnumber*3;

EndIf

a) 180

b) 330

c) 156
d) 270

41. In the Visual Basic application, which of the following are listed in a properties window?

a) Items

b) Values

c) Attributes

d) Objects

42. What will be the output of the following Visual Basic expression?

Financial.Pmt (0.05, 3, 9000)

a) -3043.88

b) -3034.88

c) -3408.48

d) -3304.88

43. Which of the following is commonly used to perform an immediate action when clicked in Visual
Studio?

a) Button control

b) Close

c) End

d) Exit

44. In the following Visual Basic code, what will be in msg, if str contains “visual basic”?

Dim str as String

Dim msg as String

If str.toUpper=”VISUAL BASIC”

msg=”VB.Net”
Else

msg=”Not Visual Basic”

EndIf

a) Bye

b) Hi

c) Logical Error

d) Compiler Error

45. Which of the following displays the list of projects contained in the Visual Basic current solution?

a) List Window

b) Project Window

c) Catalogue Window

d) Solution Explorer Window

View Answer

47. Which of the following method is used to sort an array in visual basic?

a) Array.Sort()

b) Array.sortAscending()

c) Array.arrayArrange()

d) Array.arrange()

View Answer

48. Which of the following is the caption part for the following Visual Basic command?

MessageBox.Show("Delete Visual Basic?","VB.Net",MessageBoxButtons.YesNo,

MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2).

a) MessageBoxButtons.YesNo

b) MessageBoxIcon.Exclamation

c) “VB.Net”

d) “Delete Visual Basic?”


49. Which of the following instruction tells the computer to close the current form in Visual Basic?

a) This.Close()

b) Me.Close()

c) Close.this()

d) Close()

50. Object respond to an event by writing __________

a) Defining events

b) Operations

c) Defining actions

d) Event procedures

51. What output will be returned if the following Visual Basic code is executed?

strVisualBasic = "Sanfoundry, VB.Net"

intCharIndex = strVisualBasic.IndexOf("VB")

a) 11

b) 12

c) False

d) True

52. What will be the output of the following Visual Basic code?

Dim intScores As Integer = {78, 83, 75, 90}

Array.Reverse(intScores)

a) 78,75,83,90

b) 90,75,83,78

c) 78, 83, 75,90


d) 75,78, 83,90

53. Which of the following is used to write a stream of characters in Visual Basic?

a) StreamReader object

b) StreamReader class

c) StreamWriter object

d) StreamWriter class

54. What is the value of len in the following Visual Basic code?

Dim strVB() As String = {"Sanfoundry", "Visual Basic", "VB.Net", "Visual Studio"}

Dim len As Integer

len = strVB.Length()

a) 3

b) 5

c) 4

d) 0

55. Which of the following is the default name assigned to the label control in Visual Basic?

a) Label1

b) DefaultLabel

c) Label0

d) NewLabel

56. Which of the following toolbox is used to include an image on the Visual Basic form?

a) Add Image box

b) Picture Box

c) Add Picture Box


d) Image box

57. In visual basic language what are the rules of a programming language called?

a) Grammar

b) Order

c) Syntax

d) Rules

58. What happens when both the minimize box and maximize box property are set to false in Visual
Basic?

a) Both are removed from the title bar

b) Both are disabled

c) This situation shows an exception

d) This situation shows an error

59. In Visual Basic, which of the following keyword tells the computer to pass the variable’s address
rather than its contents?

a) ByAdd

b) ByPoint

c) ByRef

d) ByVal

60. Which of the following forces a literal constant to assume a data type other than the one its form
indicates?

a) Any literal

b) Keyword

c) Literal type constant

d) Literal type variable

61. Which of the following is used to display a message box in Visual Basic?
a) MessageBox.Show

b) MessageBox.show

c) MessageBox

d) AlertBox.View

62. In Visual Basic, which of the following method converts a string to a number?

a) Convert

b) Tryparse

c) Extern

d) Parse

63. Which of the following is used to convert a number from one data type to another in visual studio?

a) Literal constant

b) Object

c) Convert class

d) Parser

64. Which of the following type of constant is ControlChars.NewLine constant?

a) Character

b) Pure

c) Intrinsic

d) Invariable

65.Which value for x would make the following condition true: Not (x >= 5)

A. x is equal to 7

B. x is equal to 4

C. x is equal to 5.001

D. x is equal to 5.001
67Which value for x would make the following condition true: (x >= 5) And (x <= 6)

A. x is equal to 7

B. x is equal to 5

C. x is equal to 5.001

68. Constructs in which an If block is contained inside another If block are called:

A. multi-If blocks

B. nested If blocks

C. sequential If blocks

D. none of the above

69. One may use an If block within a Select Case block.

A. True

B. False

70. One may use a Select Case block within an If block.

A. True

B. False

71. Select Case choices are determined by the value of an expression called a selector.

A. True

B. False

72. Items in the value list must evaluate to a literal of the same type as the selector

A. True

B. False

72. A single Case statement can contain multiple values.

A. True

B. False
73. You can specify a range of values in a Case clause by using the To keyword.

A. True

B. False

74. A variable declared inside a Select Case block cannot be referred to by code outside of the block.

A. True

B. False

75. Suppose that the selector in a Select Case block is the string variable myVar. Which of the following
is NOT a valid Case clause?

A. Case “Adams”

B. Case “739”

C. Case (myVar.Substring(0, 1)

D. Case myVar.Length

76. Different items appearing in the same value list of a Select Case block must be separated by a
____________.

A. semi colon

B. comma

C. colon

D. pair of quotation marks

77. Which Case clause will be true whenever the value of the selector in a Select Case block is between 1
and 5 or is 8?

A. Case 1 To 8

B. Case 1 To 5, 8

C. Case 1 To 8, 5

D. Case 1 To 5; 8
78. Which Case clause will be true whenever the value of the selector in a Select Case block is greater
than or equal to 7?

A. Case Is >7

B. Case Is = 8

C. Case Is >= 7

D. Case Is <= 8

79. What type of items are valid for use in the value list of a Case clause?

A. literals

B. variables

C. expressions

D. all of the above

80. What happens to a variable declared locally inside a Sub procedure after the procedure terminates?

A. It maintains its value even after the End Sub statement executes.

B. It ceases to exist after the End Sub statement executes.

C.It loses its value temporarily after the End Sub statement executes, but regains that value upon re-
entry to the Sub procedure.

D. It is reset to its default value.

81. Suppose a variable is passed by reference to a parameter of a Sub procedure, and the parameter has
its value changed inside the Sub procedure. What will the value of the variable be after the Sub
procedure has executed?

A. It will have the newly modified value from inside the Sub procedure.

B. Its value can?t be determined without more information.

C. It will retain the value it had before the call to the Sub procedure

D. None of the above.

82. Suppose a variable is passed by value to a parameter of a Sub procedure, and the parameter has its
value changed inside the Sub procedure. What will the value of the variable be after the Sub procedure
has executed?
A. It will have the newly modified value from inside the Sub procedure.

B. Its value can?t be determined without more information

C. It will retain the value it had before the call to the Sub procedure

D. None of the above.

83. The declaration statement for a class-level variable should be placed __________.

A. inside an event procedure

B. inside a general procedure

C. anywhere in the program region, except inside a procedure

D. above the statement Public Class frmName

84. Variables declared inside a procedure are said to have ________________.

A. local scope

B. procedure-level scope

C. class-level scope

D. none of the above

85. What will be the output of the following program when the button is clicked?

Private Sub btnDisplay_Click(…) Handles btnDisplay.Click

Dim number As Double = 3

DoubleAndSquare(number)

txtBox.Text = CStr(number)

End Sub

Sub DoubleAndSquare(ByRef myVar As Double)

myVar = myVar + myVar

myVar = myVar * myVar

A. 3

B. 36
C. 6

D. 0

86. Suppose the variable myName is declared in a Dim statement in two different Sub procedures.
Which statement is true?

A. The program will malfunction when it is executed.

B. When the value of myName is changed in one Sub procedure, it will also be changed in the other Sub
procedure.

C. Visual Basic’s smart editor will alert you that this is an error before the program is executed.

D. The two variables will be local to their respective Sub procedures.

87. Which of the following statements is guaranteed to pass the variable numVar by value to the Sub
procedure Tally?

A. Tally(numVar)

B. Tally(ByVal numVar)

C. Tally((numVar))

D. Tally(ByVal numVar As Double)

88. The ______________ of a Sub procedure are vehicles for passing numbers and strings to the Sub
procedure.

A. Call Statements

B. arguments

C. parameters

D. variables declared inside

89. Which of the following is NOT a reason for using procedures?

A. They break a complex problem down into smaller pieces.

B. They make a program run faster.

C. They can be reused easily.

D. They make it possible for a team of people to work together on a single program.
90. Which one of the following is true about arguments and parameters?

A. Arguments appear in Call statements; parameters appear in Sub statements.

B. Parameters appear in Call statements; arguments appear in Sub statements.

C. They are synonymous terms.

D. They are completely unrelated in a program.

91. Each individual variable in the list student(0), student(1), student(2) is known as a(n)

A. subscript

B. dimension

C. element

D. type

You might also like