VB.NET Technical Interview Questions Answers


VB.NET Technical Interview Questions Answers

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 backward-compatible with VB6, and any code written in the old version does not compile under VB.NET.


What is the entry point method of the VB.NET program?

Sub Main indicates the entry point of the VB.Net program.

What are Shared methods?

Shared methods or static methods can be invoked without creating an object of the class.

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.

What are Shadows variables?

Shadows indicate that the variable re-declares and hides an identically named element, or set of overloaded elements, in a base class.

What are Static variables?

Static indicates that the variable will retain its value, even when after the termination of the procedure in which it is declared.


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.


What is the purpose of the 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.

What is the purpose of the Assembly keyword in VB.NET?

Assembly − Specifies that an attribute at the beginning of a source file applies to the entire assembly.

What is the purpose of the 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.

What is the purpose of the 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.


What is the purpose of the 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.


What is the purpose of the 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

What is the purpose of the Default keyword in VB.NET?

Default − Identifies a property as the default property of its class, structure, or interface.

What is the purpose of the 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. 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.

What is the purpose of In keyword in VB.NET?

In − It is used in generic interfaces and delegates.

What is the purpose of the 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.

What is the purpose of Key keyword in VB.NET?

Key − The Key keyword enables you to specify behavior for properties of anonymous types.

What is the purpose of the 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 the same as the Module statement.

What is the purpose of the 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.

What is the purpose of the MustOverride keyword in VB.NET?

MustOverride − Specifies that property or procedure is not implemented in this class and must be overridden in a derived class before it can be used.


What is the purpose of Narrowing keywords 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.



What is the purpose of the NotInheritable keyword in VB.NET?

NotInheritable − Specifies that a class cannot be used as a base class.


What is the purpose of the NotOverridable keyword in VB.NET?

NotOverridable − Specifies that property or procedure cannot be overridden in a derived class.

What is the purpose of the Optional keyword in VB.NET?

Optional − Specifies that a procedure argument can be omitted when the procedure is called.

What is the purpose of Out keyword in VB.NET?

Out − For generic type parameters, the Out keyword specifies that the type is covariant.


What is the purpose of the Overloads keyword in VB.NET?

Overloads − Specifies that property or procedure redeclares one or more existing properties or procedures with the same name.


What is the purpose of the Overridable keyword in VB.NET?

Overridable − Specifies that property or procedure can be overridden by an identically named property or procedure in a derived class.


What is the purpose of the Overrides keyword in VB.NET?

Overrides − Specifies that property or procedure overrides an identically named property or procedure inherited from a base class.


What is the purpose of the 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.


What is the purpose of the Partial keyword in VB.NET?

Partial − Indicates that a class or structure declaration is a partial definition of the class or structure.


What is the purpose of the 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.


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.


What is the purpose of Public keyword in VB.NET?

Public − Specifies that one or more declared programming elements have no access restrictions.


What is the purpose of the ReadOnly keyword in VB.NET?

ReadOnly − Specifies that a variable or property can be read but not written.


What is the purpose of the 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.


What is the purpose of the 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.


What is the purpose of the 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 the termination of the procedure in which they are declared.


What is the purpose of the 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.


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.


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.


What is the purpose of WriteOnly keyword in VB.NET?

WriteOnly − Specifies that a property can be written but not read.


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!"


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)


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


What is the purpose of the 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


What is the purpose of the 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


What is the purpose of the 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


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


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


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


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


What is the purpose of the 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


What is the purpose of the 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


What is the purpose of Event statement in VB.NET?

Event Statement − Declares a user-defined event. Public Event Finished()


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


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. What is the purpose of AddressOf operator in VB.NET? AddressOf − Returns the address of a procedure. AddHandler Button1.Click, AddressOf Button1_Click


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()


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())


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))

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 the operator can be called with three arguments or with two arguments.


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.


What is the purpose of the 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.


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 the GoTo statement in your program.


What are dynamic arrays in VB.NET?

Dynamic arrays are arrays that can be dimensioned and re-dimensioned as per the need of the program. You can declare a dynamic array using the ReDim statement.


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)(){}


What is ArrayList in VB.NET?

It represents an ordered collection of an object that can be indexed individually. It is basically an alternative to an array. However, unlike an 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.

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 a 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.


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.


What is Stack in VB.NET?

It represents a last-in, first-out collection of objects. It is used when you need last-in, first-out access of items. When you add an item to the list, it is called pushing the item, and when you remove it, it is called popping the item.


What is Queue in VB.NET?

It represents a first-in, first-out collection of objects. It is used when you need first-in, first-out access of items. When you add an item to the list, it is called en queue, and when you remove an item, it is called deque.


What is BitArray in VB.NET?

It represents an array of 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.


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.


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 exceptions.


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 the file (read operation) and the output stream is used for writing into the file (write operation).


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.


Briefly explain StreamReader class.

The StreamReader class inherits from the abstract base class TextReader that represents a reader for reading a series of characters. It is used for reading text files.


Briefly explain StreamWriter class.

The StreamWriter class inherits from the abstract class TextWriter that represents a writer, which can write a series of characters. It is used for writing to text files.


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.


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.

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.


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.


What are the components of a Visual Basic Control?

Properties − Describes the object.
Methods − Cause an object to do something.
Events − Happens when an object does something.


What is the purpose of VB.NET Form control?

It represents the container for all the controls that make up the user interface.

What is the purpose of VB.NET TextBox control?

It represents a Windows text box control.


What is the purpose of VB.NET Label control?

It represents a standard Windows label.


What is the purpose of VB.NET Button control?

It represents a Windows button control.


What is the purpose of VB.NET ListBox control?

It represents a Windows control to display a list of items.


What is the purpose of VB.NET ComboBox control?

It represents a Windows combo box control.


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.


What is the purpose of VB.NET PictureBox control?

It represents a Windows picture box control for displaying an image.


What is the purpose of VB.NET ProgressBar control?

It represents a Windows progress bar control.


What is the purpose of VB.NET ScrollBar control?

It Implements the basic functionality of a scroll bar control.


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.


What is the purpose of VB.NET TreeView control?

It displays a hierarchical collection of labeled items, each represented by a TreeNode.


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.
Previous Post Next Post