Monday, April 19, 2010

VB .Net Interview Questions

1) Explain about visual basic?
Visual basic is associated with the IDE of Microsoft. It is basically useful to implement RAD of GUI. Creation of Active X scripts are very easy and efficient through VB. Windows API can also be used to create application on windows desktop and its applications. This was primarily designed to create applications for windows platform.

2) Explain about .NET?
.NET is a Microsoft Framework and a software component. .NET has a large library of pre-coded solutions which provided developer significant help in developing applications with solutions already present. It offers reliable security and cross platform compatibility.

3) Name some of the features present in VB 2005?
Some of the features present in VB 2005 are as follows: -
• Edit and continue: - It allows developers to modify and execute applications almost simultaneously.
• Namespace: - This provides access to various parts of the .NET framework and it also dynamically generates classes.
• Data source binding function is very useful for client server development.

4) Explain and brief about rapid application development tool?
Rapid action development tool describes about the software development process. This tool gives flexibility in iterative development and prototype deployment. It enhances the speed of application development. It is also used for application maintenance.

5) Describe about Visual basic.NET?
This is used in conjunction with Microsoft .NET platform and is a successor to visual basic sixth version. Visual basic is used in conjunction with.NET Framework. This tool has a serious defect it is not compatible with Microsoft visual basic sixth version. It has a huge library which assists programmers.

6) What are the various open source tool available for VB.NET?
When compared with the rapid development of open source tools for other languages from Microsoft (C#, etc) we can say that development of tools for VB has been slow. Mono development platform is one which is implementing VB libraries and is working on a compiler.

7) Explain about the performance of Visual basic?
Visual basic 5 and 6 are efficient in coding the code to native or P-code depending upon the programmer. Portability is a major addition to the performance of VB.NET and the code is also small. Additional layer is provided which interprets the code and this can be avoided by using special algorithms and native code programming.

8) Compare C# and Visual basic.NET?
.NET Frame work includes two languages which are language to IL compilers and in this C# and VB.NET are provided. The importance and flexibility of these as better programming languages is still questionable. Visual basic has been updated and revised to make it object oriented whereas C# has concepts from many languages such as Delphi, Java, etc and syntax from C and Java.

9) Explain about Visual basic.NET culture?
VB was always a RAD tool and it was always user friendly for any type of user whether professional or not. It also provided many users with shortcuts and features which made this language popular among many users. It had its share of debugging and maintenance issues of course.

10) Name and explain some of the exclusive features which are present in VB?
Some of the features which are exclusive to VB are as follows: -
1) Name space can be hidden which can be disabled.
2) Certain project files can be hidden and a user can show them if he intends to do.
3) Lots and lots of shortcuts are present which ease the development of programs.
4) Using the AddressOf myObject function a delegate can be made.

11) Name a feature which is common to all .NET languages?
There is only one feature which is common to all languages and that is Garbage collection or GC. This feature is automated which relieves developers of much work. This garbage is disposed only when there is need of memory or stress for memory. GC feature halts the application for few seconds before restarting it.

12) Name some of the features of C# which are not present in VB.NET?
Some of the features which are not present in VB are as follows they are: -
1) It supports unsafe code blocks for improved performance.
2) Partial interfaces and anonymous methods.
3) Multi line comments and static classes. Etc

13) Explain about the keyword Must Inherit?
This keyword prevents a class from directly instantiated. This keyword forces users to create references to only derived classes. This keyword is present in C# as abstract and it is very useful in creating applications.

14) What would you do to remove Microsoft visual basic name space?
.NET has many new features and application supportive tools. To remove Microsoft visual basic name space all you have to do is to
1) Remove the import manually every time you start the project.
2) Creating a template which does not contain Microsoft Visual Basic namespace.
3) About new features and changes names you can refer to MSDN.

15) Which is the tool which can convert Visual basic old version to .NET compatibility version?
There is a tool available which can convert old visual basic functions into new .NET code. Artin soft Visual basic upgrade Companion is very useful in converting VB code into .NET code. This tool was developed by Artin. This tool is integrated in Visual studio.NET 2005. It handles programs such as structured handling, error handling, etc.

16) Explain about the feature Anonymous type?
Anonymous type is a feature of VB.NET and it allows data types to be created from the code which requires it. This feature is present in VB as well as C#. They should be stored in variables declared with the keyword VAR. Dynamic typing is different and shouldn’t be confused with Anonymous type.

17) Explain about the Ruby interface generator?
Ruby interface generator is primarily responsible for providing the visual part of the Visual basic and this was clubbed with “EB” designed for Omega database system. VBX interface was added to this feature which had the ability to load dynamic link libraries.

18) To define abstract method which keyword is used in VB?

MustOverride keyword is used to define an abstract method in VB.

19) To define abstract class in VB which keyword is used?

MustInherit keyword is used to create an abstract class in VB.

20) Equivalent keyword of new in VB?

Shadow keyword is used to hide a method from a base class.

21) What is the keyword used in VB to carry out the work of virtual keyword of C#?

The Overridable keyword. It declare a method to support polymorphism.

22) Which method is used to delete a file in VB.NET?

Kill(File name with path) :- This method deletes the said file/files from the disk. The name of the file

to be deleted is passed to this method as string type arguments. Files are simply deleted and not moved to recycle-bin. The use of wild card(* and /) is permitted in this function.

Kill("C:\Files\abc.txt")This will delete the file abc.txt locates in C:\Files\

Kill("C:\Files\*.txt")This will delete all the files with .txt extension from C:\Files\

23) To reverse a string which function is used in VB.NET?

StrReverse(String):- This function reverse the specified string.

Dim Str,RStr As String

Str="Welcome"

RStr=StrReverse(Str)'returns"emocleW"

24) Name the method in VB.NET used to define a control's color?

RGB()

25) What is VAL function?

This function is used to return integer part contained in the string argument.

It stops reading further as soon as first invalid character is recognized.

Valid characters for this function are: Blanks, tabs, and linefeed characters,

radix prefixes &O (for octal) and &H (for hexadecimal) and period(.)

test = Val(" 1 2 3 4") ' Returns 1234

test = Val("1 cannot be 2") 'Returns 1

With Visual Basic Runtime, NOTHING gets evaluated as,

NOTE: This is objective type question, Please click question title for correct answer.

26) What is difference between String.Substring and MID function?

Said both performs the same type of operation on string. The basic difference lies, how they indice the string characters.

In case, if you have got string "TEST", the MID function will indice the characters as 1,2,3,4. But with String.substring they will be indiced as 0,1,2,3.

27) What is difference between Mid function and Mid Statement ?

Mid function returns the characters while the Mid statement replaces the characters.

28) Write output: Dim testString = "TestingStringHere" Mid(testString, 5) = "..Bore.."

"Test..Bore..gHere"

Justification : here we have used is MID statement not the MID function.

29) Difference between Fix and Int.

Both of them returns integer part of the provided number. Difference lies, how they deal with the negative numbers.

Fix returns the first negative integer greater than or equal to provided Number while Int returns the first negative integer less than or equal to provided Number.

For an example,

Int(-99.2) ' Returns -100.

Fix(-99.2) ' Returns -99.

30) What is “fix” ?

Fix is a function available in VB, which returns integer part of the number.

31) ____________ when turned on do not allow to use any variable without proper declaration?

Option Explicit

32) _________ when turned on do not allow incompatible type conversion?

Option Strict

DateTime variables can be null.

NOTE: This is objective type question, Please click question title for correct answer.

33) Have you ever used IIF? Explain.

Sometimes, you need to bind data using ternary functions from code file. With VB, you can achieve this thing using IIF function.

For an example, here in code below at the time of databinding I need to check value of “testString”. If the value is null/empty string it shows “NA” else the value.

<%#IIf(String.IsNullOrEmpty(DataBinder.Eval(Container.DataItem, "testString")), "NA", DataBinder.Eval(Container.DataItem, " testString "))%>

You can achieve the same result from code behind by placing appropriate code in itemdatabound method.(if applicable)

34) How to assign width to label/button/textbox in vb.net ?

With some scenarios you need to assign width to the controls rubtime. Generally we tend to make it soecified with percentage. At runtime we can use following way to make such assignments.

Label1.Width = Unit.Percentage(12.12)

You can have “pixel” or “point” as measurement unit and get your desired result set.

35) How to assign font to label at run-time in vb.net ?

Label1.Font.Size = 12

Label1.Font.Name = "Broadway"

36) Which Keyword is used in VBScript to increase or decrease the counter variable by the value?

NOTE: This is objective type question, Please click question title for correct answer.

37) What is the default size of Integer data type in VB.NET as VB.NET has Int 16, Int 32 and Int 64 also?

The default size of Integer data type is 32 bit.

38) How to deal with return value of stored procedure when you are using DataReader ?

To deal with such scenario, you can find “ParameterDirection.ReturnValue”.

You can use this parameter direction to read the return value of the stored procedure.

Following example can make it more clearer.

In case, you have following or similar type of return statement somewhere in your stored procedure.

Return -999

To read this value, following code works,

Dim result As Integer = 0

Dim retValParam As New SqlClient.SqlParameter("@RETURN_VALUE", SqlDbType.Int)

retValParam.Direction = ParameterDirection.ReturnValue

dbCommand.Parameters.Add(retValParam)

database.ExecuteNonQuery(dbCommand)

result = retValParam.Value ‘ here the result must contain the returned value. In this case, it will be -999

39) How to find data with generics list in VB.NET (Write code).

In the code example below, the function “FindData” will return list(“sublist”) of the objects having matchingKey same as viewstate value.

Dim sublist As List(Of MyClass)

sublist = allClient.FindAll(AddressOf FindData) ‘sublist will contain objects matching specified matching condition

Function FindData(ByVal b As MyClass) _

As Boolean

If (b.matchingKey = CInt(ViewState("matchingKey "))) Then ‘matching condition

Return True

Else

Return False

End If

End Function

No comments: