VB.Net Study Test
Practice tests to further your career.
Intro
The following study test contains practice certification questions along with a study link for each question.
These questions were prepared by Mike Prestwood and are intended to stress an important aspect. All our practice questions are intended to prepare you
specifically to earn your Prestwood certification and generally for passing any certification test as well as prepare you for
professional work.
Features:
Each question has a popup [Review] link.
Hover over answers to reveal correct answer.
29 Questions
Mouse over answers to reveal correct answer.
Beginner
16 Beginner Level Questions
Question #1: True or False?
VB.Net compiles to true Win32 and/or Win64 native code applications that do not require the .Net framework.
Answer:
Question #2: True or False?
Although tailored to the .Net framework, VB.Net syntax is similar to VB Classic, ASP Classic, and Access VBA.
Answer:
Question #3: True or False?
The VB.Net multiple line comment is {} as in:
{ This is a multiple line comment. }
Answer:
Question #4: True or False?
The VB.Net single line comment is ' and REM as in the following examples:
'Single line comment. REM Old school BASIC single line comment.
Answer:
Question #5: True or False?
In VB.Net, you can combine multiple statements on one line as in the following:
s =
"Mike" MessageBox.Show(s)
Answer:
Question #6: True or False?
To split a statement into two or more lines use a space plus an underscore " _" as in the following:
MessageBox. _ Show _ ("hello")
Answer:
Question #7: Multiple Choice
Which of the following code statements correctly embeds a quoted string within a quoted string?
Answer:
1. MessageBox.Show("Hi \"Brian\".")
2. MessageBox.Show('Hi "Brian".')
3. MessageBox.Show("Hi \qBrian\q.")
4. MessageBox.Show("Hi ""Brian"".")
Question #8: Multiple Choice
The correct syntax for a declaritive variable assignment is?
Answer:
1. Dim Married As String := "N"
2. Dim Married As String == "N"
3. Dim Married As String, Married = "N"
4. Dim Married As String = "N"
Question #9: True or False?
Both Subs and Functions are always methods of a class. A Sub does not return a value while a Function does.
Answer:
Question #10: Multiple Choice
What is the correct syntax for an if statement?
Answer:
1. If x Then MessageBox.Show("hello") Else If Not x Then MessageBox.Show("goodbye") Else MessageBox.Show("what?") End If
2. If (x) MessageBox.Show("hello") ElseIf (Not x) MessageBox.Show("goodbye") Else MessageBox.Show("what?") End If
3. If x Then MessageBox.Show("hello") ElseIf Not x Then MessageBox.Show("goodbye") Else MessageBox.Show("what?") End If
4. If x Then MessageBox.Show("hello") ElseIf Not x Then MessageBox.Show("goodbye") Else MessageBox.Show("what?")
5. If (x) MessageBox.Show("hello") Else If (Not x) MessageBox.Show("goodbye") Else MessageBox.Show("what?")
Question #11: Multiple Choice
Which statement is the correct syntax to assign a string value to a string variable?
Answer:
Question #12: Multiple Choice
Which code statement is the correct use of the comparison operator?
Answer:
1. If x = True Then MessageBox.Show("x is true") End If
2. If x == True Then MessageBox.Show("x is true") End If
3. If (x = True) MessageBox.Show("x is true") End If
4. If (x == True) MessageBox.Show("x is true") End If
5. If (x == True) Then MessageBox.Show("x is true") End If
Question #13: True or False?
In .Net, a string can be null or empty. The .Net framework offers a static method in the string class: String.IsNullOrEmpty to check if a string is null or empty.
Answer:
Question #14: Multiple Choice
What are the logical operators?
Answer:
4.
And
AndAlso
Or
OrElse
Not
XOR
Question #15: True or False?
In VB.Net you can declare and make use of same named-different case variables as in the following:
Dim MyName As String Dim MYNAME As String
Answer:
Question #16: Multiple Choice
Which statement best describes VB.Net constants?
Answer:
1. In VB.Net, you define constants with the Constant keyword. All constants are part of a class but you can have special global constants by making use of the special _Global class.
2. In VB.Net, you define constants with the Const keyword. All constants are part of a class (no global constants) but you can make a constant public and have access to it using ClassName.ConstantName so long as you have added the class to the project. This works even without creating the class as if the public constants were static, but you cannot use the Shared keyword.
3. In VB.Net, you define constants with the Literal keyword. All constants are part of a class (no global constants) and you must create a class prior to accessing the constant using ClassName.ConstantName .
4. In VB.Net, you define constants with the Const keyword. You can declare constants witin a class or globally outside a class. For class constants, you can have access to it using ClassName.ConstantName so long as you have added the class to the project.
Intermediate
8 Intermediate Level Questions
Question #17: Multiple Choice
Given these 3 lines of code:
'1. Public Class Cyborg Inherits System.Object End Class '2. Public Class Cyborg Inherits Object End Class '3. Public Class Cyborg End Class
Which of the following statements is most accurate?
Answer:
4. All of the above. All three are equivalent.
5. None of the above. All three are not equivalent.
Question #18: Yes or No?
If you do not create a developer defined constructor, does VB.Net create an implicit constructor and initialize all member fields to their default values?
Answer:
Question #19: Multiple Choice
The method name of a constructor is?
Answer:
3. ~ + class name, i.e. ~Person
Question #20: Multiple Choice
Which of the following syntax templates is used for error handling?
Answer:
4. Try Handle Exception Do Final End Try
5. Try Exception Cleanup End Try
Question #21: Multiple Choice
What is the correct syntax for class inheritance?
Answer:
1. Public Class Android End Class Public Class T-600 : Android End Class
2. Public Class Android End Class Public Class T-600 Inherits Android End Class
3. Public Class Android End Class Public Class T-600 As Android End Class
4. Public Class Android End Class Public Class T-600(Android) End Class
5. Public Class Android End Class Public Class T-600 Parent Android End Class
Question #22: Multiple Choice
Which of the following statements best describes by value and by reference parameters?
Answer:
1. For parameters, you can optionally specify ByVal or ByRef . ByRef is the default if you don't specify.
2. For parameters, you must specify either Val or Ref . There is no default.
3. For parameters, you can optionally specify Val or Ref . Ref is the default if you don't specify.
4. For parameters, you can optionally specify Val or Ref . Val is the default if you don't specify.
5. For parameters, you can optionally specify ByVal or ByRef . ByVal is the default if you don't specify.
Question #23: Multiple Choice
Which of the following statements is true?
Answer:
1. To refer to the current instance of a class or structure, use the Self keyword.
2. To refer to the current instance of a class or structure, use the This keyword.
3. To refer to the current instance of a class or structure, use the Me keyword.
Question #24: Multiple Choice
Which code snippet is the correct syntax for declaring and using an associative array?
Answer:
1. //Imports System.Collections.Generic Dim States As New Collection States.Add("CA", "California") States.Add("NV", "Nevada") MsgBox(States("NV"))
2. //Imports System.Collections.Generic Dim States As New _ Collection(Of String, String) States("CA") = "California" States("NV") = "Nevada" MsgBox(States.Item("NV"))
3. //Imports System.Collections.Generic Dim States As New Collection(Of String) States.Add("CA", "California") States.Add("NV", "Nevada") MsgBox(States.Item("NV"))
4. //Imports System.Collections.Generic Dim States As New _ Dictionary(Of String, String) States.Add("CA", "California") States.Add("NV", "Nevada") MsgBox(States("NV"))
5. //Imports System.Collections.Generic Dim States As New Array(String, String) States.Add("California", "CA") States.Add("Nevada", "NV") MsgBox(States.ListItem("NV"))
Advanced
5 Advanced Level Questions
Question #25: Multiple Choice
Which statement best describes pointer support in VB.Net?
Answer:
1. VB.Net doesn't support pointers. The closest it comes is IntPtr which you use to get pointer handles on windows, files, etc.
2. VB.Net supports developer defined pointers. Use the * operator to declare a pointer data type. Use the & operator to return the current address of a variable.
3. VB.Net supports developer defined pointers. Use a carrot (^ ) to declare a pointer data type. Use the @ operator or Addr function to return the current address of a variable.
Question #26: Multiple Choice
Which answer best describes VB.Net's support for static members and clsasses?
Answer:
1. VB.Net supports both static members and static classes (use the keyword Static ). You can add a static method, field, property, or event to an existing class.
2. VB.Net supports both static members and static classes (use the keyword Shared ). You can add a static method, field, property, or event to an existing class.
3. VB.Net supports static members only (use the keyword Shared ).
4. VB.Net supports static classes only (use the keyword Static ).
5. None of the above. VB.Net does not support static classes nor members.
Question #27: True or False?
With all .Net languaes, inlining is automatically done for you by the JIT compiler and in general leads to faster code for all programmers whether they are aware of inlining or not.
Answer:
Question #28: Multiple Choice
Which of the following statements best describes method overloading?
Answer:
1. For method overloading, you use implicit overloading (no special syntax) .
2. For method overloading, you either use implicit overloading (no special syntax) or use the Overloads keyword. If you use the Overloads keyword, all overloaded methods with the same name in the same class must include the Overloads keyword.
3. For method overloading, you use the Overloads keyword. If you use the Overloads keyword, all overloaded methods with the same name in the same class must include the Overloads keyword.
4. For method overloading, you either use implicit overloading (no special syntax) or use the Override keyword. If you use the Override keyword, all overloaded methods with the same name in the same class must include the Override keyword.
5. For method overloading, you use the Implicit keyword. If you use the Implicit keyword, all overloaded methods with the same name in the same class must include the Implicit keyword.
Question #29: Multiple Choice
Given the following code snippet:
Public Class Cyborg End Class
Answer:
1. The finalizer method name must be ~Cyborg .
2. The finalizer method name can be any method name of your choosing so long as you use the finalizer keyword to indicate this is the finalizer method.
3. The finalizer method name must be Finalize .
4. The finalizer method name must be Destroy .
5. The finalizer method name must be Class_Terminate.