VB.NET Interview Questions and Answers

  • Share this blog:


1Q) Clarify the contrast between a class and an object?

Ans: In short, a class is the definition of an object, and an object is an instance of a class. We can look at the class as a template of the object: it describes all the properties, methods, states, and behaviors that the implementing object will have. As mentioned, an object is an instance of a class, and a class does not become an object until it is instantiated. There can be more instances of objects based on the one class, each with different properties.

2Q) Clarify the contrast between the while and for a loop. Give a .NET syntax for the two loops??

Ans: Both loops are used when a unit of code needs to execute repeatedly. The difference is that the for loop is used when you know how many times you need to iterate through the code. On the other hand, the while loop will be used when you need to repeat something until a given statement is true.

The syntax of the while loop in C# is:

while (condition [is true]) {  // statements }

The syntax of the while loop in VB.NET is:

While condition [is True]  ' statements End While

The syntax of the for loop in C# is:

for (initializer; condition; iterator) {  // statements }

The syntax of the for loop in VB.NET is:

For counter [ As datatype ] = start To end [ Step step ]  ' statements Next [ counter ]

 Learn VB.net by Tekslate - Fastest growing sector in the industry. Explore Online" VB.net Training "and course is aligned with industry needs & developed by industry veterans. Tekslate will turn you into VB.net Expert.

3Q) Clarify the contrast amongst boxing and unboxing?

Ans: Boxing is the process of converting a value type to the type object, and unboxing is extracting the value type from the object. While the boxing is implicit, unboxing is explicit.

4Q)Clarify what LINQ is?

Ans: LINQ is an acronym for Language Integrated Query, and was introduced with Visual Studio 2008. LINQ is a set of features that extends query capabilities to the .NET language syntax by adding sets of new standard query operators that allow data manipulation, regardless of the data source. Supported data sources are: .NET Framework collections, SQL Server databases, ADO.NET Datasets, XML documents, and any collection of objects that support IEnumerable or the generic IEnumerable<T>interface, in both C# and Visual Basic. In short, LINQ bridges the gap between the world of objects and the world of data.

5Q) What do the accompanying acronyms in .NET stand for: IL, CIL, MSIL, CLI, and JIT?

Ans: IL, or Intermediate Language, is a CPU independent partially compiled code. IL code will be compiled to native machine code using current environmental properties by the Just-In-Time compiler (JIT). JIT compiler translates the IL code to assembly code and uses the CPU architecture of the target machine to execute a .NET application. In .NET, IL is called Common Intermediate Language (CIL), and in the early .NET days, it was called Microsoft Intermediate Language (MSIL).

CLI, or Common Language Infrastructure, is an open specification developed by Microsoft. It is a compiled code library used for deployment, versioning, and security. In .NET there are two CLI types: process assemblies (EXE) and library assemblies (DLL). CLI assemblies contain code in CIL, and as mentioned, during the compilation of CLI programming languages, the source code is translated into CIL code rather than into platform or processor-specific object code.

To summarize:

  1. When compiled, source code is first translated to IL (in .NET, that is CIL, and previously called MSIL).
  2. CIL is then assembled into bytecode and a CLI assembly is created.
  3. Before code execution, the CLI code is passed through the runtime’s JIT compiler to generate native machine code.
  4. The computer’s processor executes the native machine code.

6Q) Clarify what inheritance is, and why it's essential?

Ans: Inheritance is one of the most important concepts in object-oriented programming, together with encapsulation and polymorphism. Inheritance allows developers to create new classes that reuse, extend, and modify the behavior defined in other classes. This enables code reuse and speeds up development. With inheritance, developers can write and debug one class only once, and then reuse that same code as the basis for the new classes. The class whose members are inherited is called the base class, and the class that inherits those members is called the derived class. By default, all classes in .NET are inheritable.

7Q) Clarify deferred execution versus immediate execution in LINQ?

Ans: In LINQ, deferred execution simply means that the query is not executed at the time it is specified. Specifically, this is accomplished by assigning the query to a variable. When this is done, the query definition is stored in the variable but the query is not executed until the query variable is iterated over.

For example:

DataContext product context = new DataContext(); var product query = from product in product context.Products where product.Type == "SOAPS"        select product;   // Query is NOT executed here for each (var product in product query)   // Query executes HERE {  Console.WriteLine(product.Name); }

You can also force immediate execution of a query. This can be useful, for example, if the database is being updated frequently, and it is important in the logic of your program to ensure that the results you’re accessing are those returned at the point in your code where the query was specified. Immediate execution is often forced using a method such as Average, Sum, Count, List, ToList, or ToArray. For example:

DataContext product context = new DataContext(); var productCountQuery = (from product in productContext.Products        where product.Type == "SOAPS"        select product).Count();   // Query executes HERE

8Q)For what reason wouldn't you be able to indicate get to modifiers for items in an interface?

Ans: It is always public.

 You would know that System.Object is the parent class of all .NET classes; In other words, all types in .NET (whether implicit, explicit, or user-created) derive from the System.Object class.

9Q)What are the various methods provided to System.Object’s deriving classes/types?

Ans: System.Object provides the following important methods, among others:

  1. ToString—Returns a string that represents the current object
  2. both overrides of Equals(object), Equals(object, object)
  3. GetHashCode
  4. Finalize
  5. GetType
  6. ReferenceEquals
  7. MemberwiseClone

Most of these methods provide the basic implementation required of any type that a developer will work within the .NET stack.

10Q) What is vb.net?

Ans: Vb.net is a programming language that is available in Visual Studio. Net. It contains features of visual basic which is an event-based programming language and also includes object-oriented concepts. [VB.Net is a programming language that is an extension of Visual Basic to make it compliant with the Dot Net Framework. Also, VB.Net is fully Object Oriented unlike Visual Basic and everything in VB.Net is an object. As it is compliant with the Dot Net Framework VB.Net can make full use of Framework Class Library provided by dot Net Framework.] 

11Q) How might we assign item on the list box with the goal that it will appear??

Ans: Rowwise please write the code for it.

Lisbox1.Items.Add "Prashant"

Lisbox1.Items.Add "Chinchu"

Lisbox1.Items.Add "Pallavi"

Lisbox1.Items.Add "Suresh"

Lisbox1.Items.Add "Polika". 

12Q) What are the properties that should be given to the set method??

Ans: Class Class1

‘Define a local variable to store the property value.


Private PropertyValue As String

Define the property.

Public Property Prop1() As String


‘The Get property procedure is called when the value' of a property is retrieved.

‘Return PropertyValue

End Get

Set(ByVal Value As String)

‘The Set property procedure is called when the value of a property is modified.

‘The value to be assigned is passed in the

‘argument to Set.

PropertyValue = Value

End Set

End Property

End Class.

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses


About Author
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.