1. The Visual Basic
Code Editor will automatically detect certain types of errors as you are
entering code.
A. True
B. False
Ans: A
2. Keywords are also referred to as reserved words.
A. True
B. False
Ans: A
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
Ans: A
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
Ans: B
5. When the user clicks a button, _________ is triggered.
A. an event
B. a method
C. a setting
D. a property
Ans: A
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
Ans: C
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.
Ans: C
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.
Ans: A
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.
Ans: C,B
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
Ans: D
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.
Ans: E
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.
Ans: C
13. A variable declared inside an event procedure is said to have local scope
A. True
B. False
Ans: A
14. A variable declared outside of an event procedure is said to have
class-level scope.
A. True
B. False
Ans: A
15. Option Explicit requires you to declare every variable before its use.
A. True
B. False
Ans: A
16. The value returned by InputBox is a string.
A. True
B. False
Ans: A
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
Ans: D
18. Which of the following arithmetic operations has the highest level of
precedence?
A. + –
B. * /
C. ^ exponentiation
D. ( )
Ans: C
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
Ans: B
20. Which of the following is a valid name for a variable?
A. Two_One
B. 2One
C. Two One
D. Two.One
Ans: A
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).
Ans: C
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.
Ans: A
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
Ans: A
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
Ans: D
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
Ans: B
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
Ans: A
27. Asc(“A”) is 65. What is Asc(“C”)?
A. 66
B. 67
C. 68
D. “C”
Ans: B
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.
Ans: A
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)
Ans: A
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.
Ans: B
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)
Ans: D
32. The three main logical operators are ________, _________, and ________.
A. And, Or, Not
B. And, Not, If
C. Or, Not, If
D. False, And, True
Ans: A
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
D. all of the above
Ans: D
34. 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
Ans: B
35. Which 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
Ans: B,C
36. 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
Ans: B
37. One may use an If block within a Select Case block.
A. True
B. False
Ans: A
38. One may use a Select Case block within an If block.
A. True
B. False
Ans: A
39. Select Case choices are determined by the value of an expression called a
selector.
A. True
B. False
Ans: A
40. Items in the value list must evaluate to a literal of the same type as the
selector
A. True
B. False
Ans: A
41. A single Case statement can contain multiple values.
A. True
B. False
Ans: A
42. You can specify a range of values in a Case clause by using the To keyword.
A. True
B. False
Ans: A
43. A variable declared inside a Select Case block cannot be referred to by
code outside of the block.
A. True
B. False
Ans: A
44. 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
Ans: D
45. 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
Ans: B
46. 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
Ans: B
47. 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
Ans: C
48. 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
Ans: D
49. 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.
Ans: B
50. 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.
Ans: A
51. 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.
Ans: C
52. 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
Ans: C
53. 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
Ans: A
54. 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
Ans: B
55. 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.
Ans: D
56. 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)
Ans: D
57. 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
Ans: C
58. 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.
Ans: B
59. 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.
Ans: A
60.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
Ans: C
62. The statement Const TAX_RATE As Doubleface=Calibri size=2> is not valid.
A. True
B. False
Ans: A
63. Function names should be suggestive of the role performed. The names also
must conform to the rules for naming variables.
A. True
B. False
Ans: A
64. The input to a user-defined function can consist of one or more values.
A. True
B. False
Ans: A
65. Both the input and output of a Function procedure can consist of several
values.
A. True
B. False
Ans: B
66. Suppose you want to write a procedure that takes three numbers, num1, num2,
and num3; and returns their sum, product, and average. It is best to use a
Function procedure for this task.
A. True
B. False
Ans: B
67. Although a function can return a value, it cannot directly display
information in a text box.
A. True
B. False
Ans: B
68. Function procedures can invoke other Function procedures.
A. True
B. False
Ans: A
69. A Function may return up to two values.
A. True
B. False
Ans: B
70. The input to a user-defined function can consist of:
A. a single value
B. one or more values
C. no values
D. All of the above
Ans: D
71. Variables appearing in the header of a Function procedure are called
____________.
A. values of the function
B. parameters
C. coordinates
D. arguments
Ans: B
72. The arguments appearing in a Call statement must match the parameters in
the appropriate Sub or Function header in all but one of the following ways.
Which one?
A. Number of arguments
B. Names of arguments
C. Data type of arguments
D. Order of arguments
Ans: B
73. What will be the output of the following program when the button is
clicked?
Private Sub btnDisplay_Click(…) Handles btnDisplay.Click
Dim word, result As String
word = “Benjamin”
result = Rotate(word)
result = Rotate(result & word)
result = Rotate(result)
txtBox.Text = result
End Sub
Function Rotate(ByVal var As String) As String
Dim varlength As Integer
varlength = var.Length
Return var.Substring(1) & var.Substring(0, 1)
End Function
A. jaminBBenjaminen
B. BenjaminBenjamin
C. njaminBe
D. None of the above
Ans: A
74. What is displayed when the button is clicked?
Private Sub btnDisplay_Click(…) Handles btnDisplay.Click
Dim a, b as String
Dim x as Integer
a = “How now brown cow.”
b = “brown”
x = FindIt(a, b)
txtBox.Text = CStr(x)
End Sub
Function FindIt(ByVal z1 as String, ByVal z2 as String) As Integer
Dim x as Integer
x = z1.IndexOf(z2)
End Function
“How now”
A. 8
B. 0
C. An error
D. None of the above
Ans: D
75. A Do While loop checks the While condition before executing the statements
in the loop.
A. True
B. False
Ans: A
76. A Do?Loop Until block is always executed at least once
A. True
B. False
Ans: A
77. A counter variable is normally incremented or decremented by 1.
A. True
B. False
Ans: A
78. The value of the control variable should not be altered within the body of
a For?Next loop.
A. True
B. False
Ans: B
79. The body of a For…Next loop in Visual Basic will always be executed once no
matter what the initial and terminating values are.
A. True
B. False
Ans: B
80. The body of a For…Next loop in Visual Basic will always be executed once no
matter what the initial and terminating values are. duplicate question?
A. True
B. False
Ans: B
1. What is VB.NET?
Visual Basic .NET (VB.NET) is an object-oriented
computer programming language implemented on the .NET Framework. Although it is
an evolution of classic Visual Basic language, it is not backwards-compatible
with VB6, and any code written in the old version does not compile under
VB.NET.
2. What is entry point
method of VB.NET program?
Sub Main indicates the entry point of VB.Net
program.
3. What are Shared
methods?
Shared methods or static methods can be invoked
without creating an object of the class.
4. What are Shared
variables?
Shared declares a shared variable, which is not
associated with any specific instance of a class or structure, rather available
to all the instances of the class or structure.
5. What are Shadows
variable?
Shadows indicate that the variable re-declares
and hides an identically named element, or set of overloaded elements, in a
base class.
6. What are Static
variable?
Static indicates that the variable will retain
its value, even when the after termination of the procedure in which it is
declared.
7. How to create a
constant in VB.NET?
In VB.Net, constants are declared using the
Const statement. The Const statement is used at module, class, structure,
procedure, or block level for use in place of literal values.
8. What is the purpose
of Ansi keyword in VB.NET?
Ansi − Specifies that Visual Basic should
marshal all strings to American National Standards Institute (ANSI) values
regardless of the name of the external procedure being declared.
9. What is the purpose
of Assembly keyword in VB.NET?
Assembly − Specifies that an attribute at the
beginning of a source file applies to the entire assembly.
10. What is the
purpose of Async keyword in VB.NET?
Async − Indicates that the method or lambda
expression that it modifies is asynchronous. Such methods are referred to as
async methods. The caller of an async method can resume its work without
waiting for the async method to finish.
11. What is the
purpose of Auto keyword in VB.NET?
Auto − The charsetmodifier part in the Declare
statement supplies the character set information for marshaling strings during
a call to the external procedure. It also affects how Visual Basic searches the
external file for the external procedure name. The Auto modifier specifies that
Visual Basic should marshal strings according to .NET Framework rules.
12. What is the
purpose of ByRef keyword in VB.NET?
ByRef − Specifies that an argument is passed by
reference, i.e., the called procedure can change the value of a variable
underlying the argument in the calling code. It is used under the contexts of −
· Declare Statement
· Function Statement
· Sub Statement
13. What is the
purpose of ByVal keyword in VB.NET?
ByVal − Specifies that an argument is passed in
such a way that the called procedure or property cannot change the value of a
variable underlying the argument in the calling code. It is used under the
contexts of −
· Declare Statement
· Function Statement
· Operator Statement
· Property Statement
· Sub Statement
14. What is the
purpose of Default keyword in VB.NET?
Default − Identifies a property as the default
property of its class, structure, or interface.
15. What is the
purpose of Friend keyword in VB.NET?
Friend − Specifies that one or more declared
programming elements are accessible from within the assembly that contains
their declaration, not only by the component that declares them.
16. Friend access is often the preferred level
for an application's programming elements, and Friend is the default access
level of an interface, a module, a class, or a structure.
17. What is the
purpose of In keyword in VB.NET?
In − It is used in generic interfaces and
delegates.
18. What is the
purpose of Iterator keyword in VB.NET?
Iterator − Specifies that a function or Get
accessor is an iterator. An iterator performs a custom iteration over a
collection.
19. What is the
purpose of Key keyword in VB.NET?
Key − The Key keyword enables you to specify
behavior for properties of anonymous types.
20. What is the
purpose of Module keyword in VB.NET?
Module − Specifies that an attribute at the
beginning of a source file applies to the current assembly module. It is not
same as the Module statement.
21. What is the
purpose of MustInherit keyword in VB.NET?
MustInherit − Specifies that a class can be used
only as a base class and that you cannot create an object directly from it.
22. What is the
purpose of MustOverride keyword in VB.NET?
MustOverride − Specifies that a property or
procedure is not implemented in this class and must be overridden in a derived
class before it can be used.
23. What is the
purpose of Narrowing keyword in VB.NET?
Narrowing − Indicates that a conversion operator
(CType) converts a class or structure to a type that might not be able to hold
some of the possible values of the original class or structure.
24. What is the
purpose of NotInheritable keyword in VB.NET?
NotInheritable − Specifies that a class cannot
be used as a base class.
25. What is the
purpose of NotOverridable keyword in VB.NET?
NotOverridable − Specifies that a property or
procedure cannot be overridden in a derived class.
26. What is the
purpose of Optional keyword in VB.NET?
Optional − Specifies that a procedure argument
can be omitted when the procedure is called.
27. What is the
purpose of Out keyword in VB.NET?
Out − For generic type parameters, the Out
keyword specifies that the type is covariant.
28. What is the
purpose of Overloads keyword in VB.NET?
Overloads − Specifies that a property or
procedure redeclares one or more existing properties or procedures with the
same name.
29. What is the
purpose of Overridable keyword in VB.NET?
Overridable − Specifies that a property or
procedure can be overridden by an identically named property or procedure in a
derived class.
30. What is the
purpose of Overrides keyword in VB.NET?
Overrides − Specifies that a property or
procedure overrides an identically named property or procedure inherited from a
base class.
31. What is the
purpose of ParamArray keyword in VB.NET?
ParamArray − ParamArray allows you to pass an
arbitrary number of arguments to the procedure. A ParamArray parameter is
always declared using ByVal.
32. What is the
purpose of Partial keyword in VB.NET?
Partial − Indicates that a class or structure
declaration is a partial definition of the class or structure.
33. What is the
purpose of Private keyword in VB.NET?
Private − Specifies that one or more declared
programming elements are accessible only from within their declaration context,
including from within any contained types.
34. What is the
purpose of Protected keyword in VB.NET?
Protected − Specifies that one or more declared
programming elements are accessible only from within their own class or from a
derived class.
35. What is the
purpose of Public keyword in VB.NET?
Public − Specifies that one or more declared
programming elements have no access restrictions.
36. What is the
purpose of ReadOnly keyword in VB.NET?
ReadOnly − Specifies that a variable or property
can be read but not written.
37. What is the
purpose of Shadows keyword in VB.NET?
Shadows − Specifies that a declared programming
element redeclares and hides an identically named element, or set of overloaded
elements, in a base class.
38. What is the
purpose of Shared keyword in VB.NET?
Shared − Specifies that one or more declared
programming elements are associated with a class or structure at large, and not
with a specific instance of the class or structure.
39. What is the
purpose of Static keyword in VB.NET?
Static − Specifies that one or more declared
local variables are to continue to exist and retain their latest values after
termination of the procedure in which they are declared.
40. What is the
purpose of Unicode keyword in VB.NET?
Unicode − Specifies that Visual Basic should
marshal all strings to Unicode values regardless of the name of the external
procedure being declared.
41. What is the purpose
of Widening keyword in VB.NET?
Widening − Indicates that a conversion operator
(CType) converts a class or structure to a type that can hold all possible
values of the original class or structure.
42. What is the
purpose of WithEvents keyword in VB.NET?
WithEvents − Specifies that one or more declared
member variables refer to an instance of a class that can raise events.
43. What is the
purpose of WriteOnly keyword in VB.NET?
WriteOnly − Specifies that a property can be
written but not read.
44. What is the
purpose of Dim statement in VB.NET?
Dim Statement − Declares and allocates storage
space for one or more variables.
Dim number As Integer
Dim quantity As Integer = 100
Dim message As String = "Hello!"
45. What is the
purpose of Const statement in VB.NET?
Const Statement − Declares and defines one or
more constants.
Const maximum As Long = 1000
Const naturalLogBase As Object
= CDec(2.7182818284)
46. What is the
purpose of Enum statement in VB.NET?
Enum Statement − Declares an enumeration and
defines the values of its members.
Enum CoffeeMugSize
Jumbo
ExtraLarge
Large
Medium
Small
End Enum
47. What is the
purpose of Class statement in VB.NET?
Class Statement − Declares the name of a class
and introduces the definition of the variables, properties, events, and
procedures that the class comprises.
Class Box
Public length As Double
Public breadth As Double
Public height As Double
End Class
48. What is the
purpose of Structure statement in VB.NET?
Structure Statement − Declares the name of a
structure and introduces the definition of the variables, properties, events,
and procedures that the structure comprises.
Structure Box
Public length As Double
Public breadth As Double
Public height As Double
End Structure
49. What is the
purpose of Module statement in VB.NET?
Module Statement − Declares the name of a module
and introduces the definition of the variables, properties, events, and
procedures that the module comprises.
Public Module myModule
Sub Main()
Dim user As String =
InputBox("What is your name?")
MsgBox("User name is" & user)
End Sub
End Module
50. What is the
purpose of Interface statement in VB.NET?
Interface Statement − Declares the name of an
interface and introduces the definitions of the members that the interface
comprises.
Public Interface MyInterface
Sub doSomething()
End Interface
51. What is the
purpose of Function statement in VB.NET?
Function Statement − Declares the name,
parameters, and code that define a Function procedure.
Function myFunction
(ByVal n As Integer) As Double
Return 5.87 * n
End Function
52. What is the
purpose of Sub statement in VB.NET?
Sub Statement − Declares the name, parameters,
and code that define a Sub procedure.
Sub mySub(ByVal s As String)
Return
End Sub
53. What is the
purpose of Declare statement in VB.NET?
Declare Statement − Declares a reference to a
procedure implemented in an external file.
Declare Function getUserName
Lib "advapi32.dll"
Alias "GetUserNameA"
(
ByVal lpBuffer As String,
ByRef nSize As Integer) As Integer
54. What is the
purpose of Operator statement in VB.NET?
Operator Statement − Declares the operator
symbol, operands, and code that define an operator procedure on a class or
structure.
Public Shared Operator +
(ByVal x As obj, ByVal y As obj) As obj
Dim r As New obj
' implemention code for r = x + y
Return r
End Operator
55. What is the
purpose of Property statement in VB.NET?
Property Statement − Declares the name of a
property, and the property procedures used to store and retrieve the value of
the property.
ReadOnly Property quote() As String
Get
Return quoteString
End Get
End Property
56. What is the
purpose of Event statement in VB.NET?
Event Statement − Declares a user-defined event.
Public Event Finished()
57. What is the
purpose of Delegate statement in VB.NET?
Delegate Statement − Used to declare a delegate.
Delegate Function MathOperator(
ByVal x As Double,
ByVal y As Double
) As Double
58. What is a
preprocessor directives in VB.NET?
The VB.Net compiler directives give instructions
to the compiler to preprocess the information before actual compilation starts.
All these directives begin with #, and only white-space characters may appear
before a directive on a line. These directives are not statements.
59. What is the
purpose of AddressOf operator in VB.NET?
AddressOf − Returns the address of a procedure.
AddHandler Button1.Click,
AddressOf Button1_Click
60. What is the
purpose of Await operator in VB.NET?
Await − It is applied to an operand in an
asynchronous method or lambda expression to suspend execution of the method
until the awaited task completes.
Dim result As res
= Await AsyncMethodThatReturnsResult()
Await AsyncMethod()
61. What is the
purpose of GetType operator in VB.NET?
GetType − It returns a Type object for the
specified type. The Type object provides information about the type such as its
properties, methods, and events.
MsgBox(GetType(Integer).ToString())
62. What is the
purpose of Function Expression in VB.NET?
Function Expression − It declares the parameters
and code that define a function lambda expression.
Dim add5 = Function(num As
Integer) num + 5
'prints 10
Console.WriteLine(add5(5))
63. What is the
purpose of If operator in VB.NET?
If − It uses short-circuit evaluation to
conditionally return one of two values. The If operator can be called with
three arguments or with two arguments.
64. What is the
purpose of Exit statement in VB.NET?
Exit statement − Terminates the loop or select
case statement and transfers execution to the statement immediately following
the loop or select case.
65. What is the
purpose of Continue statement in VB.NET?
Continue statement − Causes the loop to skip the
remainder of its body and immediately retest its condition prior to
reiterating.
66. What is the
purpose of GoTo statement in VB.NET?
GoTo statement − Transfers control to the
labeled statement. Though it is not advised to use GoTo statement in your
program.
67. What are dynamic
arrays in VB.NET?
Dynamic arrays are arrays that can be
dimensioned and re-dimensioned as par the need of the program. You can declare
a dynamic array using the ReDim statement.
68. What is Jagged
Array in VB.NET?
A Jagged array is an array of arrays. A Jagged
array is an array of arrays. The follwoing code shows declaring a jagged array
named scores of Integers:
Dim scores As Integer()() = New Integer(5)(){}
69. What is ArrayList
in VB.NET?
It represents ordered collection of an object
that can be indexed individually. It is basically an alternative to an array.
However, unlike array, you can add and remove items from a list at a specified
position using an index and the array resizes itself automatically. It also
allows dynamic memory allocation, add, search and sort items in the list.
70. What is Hashtable
in VB.NET?
It uses a key to access the elements in the
collection. A hash table is used when you need to access elements by using key,
and you can identify a useful key value. Each item in the hash table has a
key/value pair. The key is used to access the items in the collection.
71. What is SortedList
in VB.NET?
It uses a key as well as an index to access the
items in a list. A sorted list is a combination of an array and a hash table.
It contains a list of items that can be accessed using a key or an index. If
you access items using an index, it is an ArrayList, and if you access items
using a key, it is a Hashtable. The collection of items is always sorted by the
key value.
72. What is Stack in
VB.NET?
It represents a last-in, first out collection of
object. It is used when you need a last-in, first-out access of items. When you
add an item in the list, it is called pushing the item, and when you remove it,
it is called popping the item.
73. What is Queue in
VB.NET?
It represents a first-in, first out collection
of object. It is used when you need a first-in, first-out access of items. When
you add an item in the list, it is called enqueue, and when you remove an item,
it is called deque.
74. What is BitArray
in VB.NET?
It represents an array of the binary
representation using the values 1 and 0. It is used when you need to store the
bits but do not know the number of bits in advance. You can access items from
the BitArray collection by using an integer index, which starts from zero.
In how many ways a
function can return value in VB.NET?
In VB.Net, a function can return a value to the
calling code in two ways −
· By using the return statement.
· By assigning the value to the function name.
Can you create a function
in VB.NET which can accept varying number of arguments?
By using the params keyword, a method parameter
can be specified which takes a variable number of arguments or even no
argument.
Can you pass
additional type of parameters after using params in function definition?
No! additional parameters are not permitted
after the params keyword in a method declaration. Only one params keyword is
allowed in a method declaration.
75. Which class acts
as a base class for all exceptions in VB.NET?
VB.NET exceptions are represented by classes.
The exception classes in VB.NET are mainly directly or indirectly derived from
the System.Exception class. Some of the exception classes derived from the
System.Exception class are the System.ApplicationException and System.SystemException
classes.
76. What is the
difference between System.ApplicationException class and System.SystemException
class?
The System.ApplicationException class supports
exceptions generated by application programs. Hence the exceptions defined by the
programmers should derive from this class. The System.SystemException class is
the base class for all predefined system exception.
77. What is a stream
in VB.NET?
The stream is basically the sequence of bytes
passing through the communication path. There are two main streams: the input
stream and the output stream. The input stream is used for reading data from
file (read operation) and the output stream is used for writing into the file
(write operation).
78. Which class in
VB.NET helps in reading from, writing to and closing files?
The FileStream class in the System.IO namespace
helps in reading from, writing to and closing files. This class derives from
the abstract class Stream.
79. Briefly explain
StreamReader class.
The StreamReader class inherits from the
abstract base class TextReader that represents a reader for reading series of
characters. It is used for reading from text files.
80. Briefly explain
StreamWriter class.
The StreamWriter class inherits from the
abstract class TextWriter that represents a writer, which can write a series of
character. It is used for writing to text files.
81. Briefly explain
BinaryReader class.
The BinaryReader class is used to read binary
data from a file. A BinaryReader object is created by passing a FileStream object
to its constructor. The BinaryReader class is used for reading from a binary
file.
82. Briefly explain
BinaryWriter class.
The BinaryWriter class is used to write binary
data to a stream. A BinaryWriter object is created by passing a FileStream
object to its constructor. The BinaryWriter class is used for writing to a
binary file.
83. Explain usage of
DirectoryInfo class.
The DirectoryInfo class is derived from the
FileSystemInfo class. It has various methods for creating, moving, and browsing
through directories and subdirectories. This class cannot be inherited.
84. Explain usage of
FileInfo class.
The FileInfo class is derived from the
FileSystemInfo class. It has properties and instance methods for creating,
copying, deleting, moving, and opening of files, and helps in the creation of
FileStream objects. This class cannot be inherited.
85. What are the
components of a Visual Basic Control?
Every Visual Basic control consists of three
important elements −
· Properties − Describes the object.
· Methods − Cause an object to do something.
· Events − Happens when an object does something.
86. What is the
purpose of VB.NET Form control?
It represents the container for all the controls
that make up the user interface.
87. What is the
purpose of VB.NET TextBox control?
It represents a Windows text box control.
88. What is the
purpose of VB.NET Label control?
It represents a standard Windows label.
89. What is the
purpose of VB.NET Button control?
It represents a Windows button control.
90. What is the
purpose of VB.NET ListBox control?
It represents a Windows control to display a
list of items.
91. What is the
purpose of VB.NET ComboBox control?
It represents a Windows combo box control.
92. What is the
purpose of VB.NET RadioButton control?
It enables the user to select a single option
from a group of choices when paired with other RadioButton controls.
93. What is the
purpose of VB.NET PictureBox control?
It represents a Windows picture box control for
displaying an image.
94. What is the
purpose of VB.NET ProgressBar control?
It represents a Windows progress bar control.
95. What is the
purpose of VB.NET ScrollBar control?
It Implements the basic functionality of a
scroll bar control.
96. What is the
purpose of VB.NET DateTimePicker control?
It represents a Windows control that allows the
user to select a date and a time and to display the date and time with a
specified format.
97. What is the
purpose of VB.NET TreeView control?
It displays a hierarchical collection of labeled
items, each represented by a TreeNode.
98. What is the
purpose of VB.NET ListView control?
It represents a Windows list view control, which
displays a collection of items that can be displayed using one of four
different views.