Need to practice your Visual Basic .NET skills for an upcoming job interview? Try solving these Visual Basic .NET interview questions that test knowledge of arrays, serialization, inheritance, and other skills. We’ll provide feedback on your answers, and you can use a hint if you get stuck.
These Visual Basic .NET interview questions are examples of real tasks used by employers to screen job candidates such as VB.NET developers, back-end developers, full-stack developers, and others that require knowledge of the VB.NET programming language and the ability to use the .NET framework's class library.
1. Merge Names
Implement the UniqueNames method. When passed two arrays of names, it will return an array containing the names that appear in either or both arrays. The returned array should have no duplicates.
For example, calling MergeNames.UniqueNames({'Ava', 'Emma', 'Olivia'}, {'Olivia', 'Sophia', 'Emma'}) should return an array containing Ava, Emma, Olivia, and Sophia in any order.
- Example case: System.NotImplementedException at Module1.MergeNames.UniqueNames(String[] names1, String[] names2) in MergeNames.vb:line 6
- Each array has distinct names: System.NotImplementedException at Module1.MergeNames.UniqueNames(String[] names1, String[] names2) in MergeNames.vb:line 6
- Each array has duplicate names: System.NotImplementedException at Module1.MergeNames.UniqueNames(String[] names1, String[] names2) in MergeNames.vb:line 6
- Arrays have some names in common: System.NotImplementedException at Module1.MergeNames.UniqueNames(String[] names1, String[] names2) in MergeNames.vb:line 6
2. Folders
Implement a function FolderNames, which accepts a string containing an XML file that specifies folder structure and returns all folder names that start with startingLetter. The XML format is given in the example below.
For example, for the letter "u" and XML file:
<?xml version="1.0" encoding="UTF-8"?>
<folder name="c">
<folder name="program files">
<folder name="uninstall information" />
</folder>
<folder name="users" />
</folder>
the function should return "uninstall information" and "users" (in any order).
- Example case: System.NotImplementedException at Module1.Folders.FolderNames(String xml, Char startingLetter) in Folders.vb:line 8
- All folder names start with starting letter: System.NotImplementedException at Module1.Folders.FolderNames(String xml, Char startingLetter) in Folders.vb:line 8
- Root folder name starts with starting letter: System.NotImplementedException at Module1.Folders.FolderNames(String xml, Char startingLetter) in Folders.vb:line 8
- Complicated folder structure: System.NotImplementedException at Module1.Folders.FolderNames(String xml, Char startingLetter) in Folders.vb:line 8
3. User Input
User interface contains two types of user input controls: TextInput, which accepts all characters and NumericInput, which accepts only digits.
Implement the class TextInput that contains:
- Public sub Add(c As Char) - adds the given character to the current value
- Public function GetValue() As String - returns the current value
Implement the class NumericInput that:
- Inherits TextInput
- Overrides the Add method so that each non-numeric character is ignored
For example, the following code should output "10":
Dim input As TextInput = New NumericInput()
input.Add(CChar("1"))
input.Add(CChar("a"))
input.Add(CChar("0"))
Console.WriteLine(input.GetValue())
- Example case: System.InvalidCastException
- Adding various characters to TextInput: System.NullReferenceException
- Adding numeric characters to NumericInput: System.InvalidCastException
- Adding various characters to NumericInput: System.InvalidCastException