Group Discounts available for 3+ students and Corporate Clients

VB.NET Interview Questions and Answers

Clarify the contrast between a class and an object?

In short, a class is the definition of an object, and an object is 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.

 

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

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 ]

 

Clarify the contrast amongst boxing and unboxing?

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.

 

Clarify what LINQ is?

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.

 

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

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 Just-In-Time compiler (JIT). JIT compiler translates the IL code to an 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 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 a bytecode and a CLI assembly is created.
  3. Before code execution, 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.

 

Clarify what inheritance is, and why it’s essential?

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.

 

Clarify deferred execution versus immediate execution in LINQ?

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 productContext = new DataContext();

var productQuery = from product in productContext.Products
       where product.Type == “SOAPS”
       select product;   // Query is NOT executed here

foreach (var product in productQuery)   // 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 productContext = new DataContext();
var productCountQuery = (from product in productContext.Products
       where product.Type == “SOAPS”
       select product).Count();   // Query executes HERE

 

For what reason wouldn’t you be able to indicate get to modifiers for items in an interface?

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.

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

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 with in the .NET stack.

 

What is vb.net?

Vb.net is a programming language that is available in Visual Studio. Net. It contains features of visual basic which is event based programming language and also includes object oriented concepts. [VB.Net is a programming language which is an extension of Visual Basic to make it compliant to 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 to the Dot Net Framework VB.Net can make full use of Framework Class Library provided by dot Net Framework.]

 

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

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

 

What are the properties should be given to set method??

Class Class1

‘Define a local variable to store the property value.

Example:

Private PropertyValue As String

Define the property.

Public Property Prop1() As String

Get

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

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on VB.NET Interview Questions and Answers"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Support


    Please Enter Your Details and Query.
    Three + 6