Posts Tagged ‘vb’

General Dot Net Interview Questions

Friday, December 12th, 2008

Key differences in features of .NET 2.0 and 3.5? 
.NET 3.5 has more advanced feature than .NET 2.0.They are WCF, WPF, WCS,WF and LINQ.

Is Dot-Net platform dependent or platform indipendent?
Net is not platform independent as it needs .Net framework to run. As MS is the owner, so it is including .Net frameworks in latest versions of Windows.MS is providing service pack using which you can manage old versions of Windows and other operating systems like Unix, Linux. But not yet, .Net is running in UNIX and Linux. So it is not platform independent. As it comprises of lot of languages, you can say it as language independent.
MS is saying Windows is best operating system but they are developing Windows OS on Unix platform.Also Java, it is also not platform independent as it requires JVM (Java Virtual Machine to run). But the case is JVM is coming in all operating systems by default. So you can take it as platform independent.

What is CAS? 
CAS: CAS is the part of the .NET security model that determines whether or not a piece of code is allowed to run, and what resources it can use when it is running. For example, it is CAS that will prevent a .NET web applet from formatting your hard disk. How does CAS work? The CAS security policy revolves around two key concepts - code groups and permissions. Each .NET assembly is a member of a particular code group, and each code group is granted the permissions specified in a named permission set. For example, using the default security policy, a control downloaded from a web site belongs to the ‘Zone - Internet’ code group, which adheres to the permissions defined by the ‘Internet’ named permission set. (Naturally the ‘Internet’ named permission set represents a very restrictive range of permissions.) 

IIS port number? How We get it? 
IIS default port numbers for http is 80 , for https 81, and for ftp its 21. These are the default port numbers but we can override this port numbers while creating a website (either SSL or normal) and while creating a ftp folder. 

What is postback form and what is autopostback? 
PostBack: It means page automatically goes to server and we can just make a check whther our page is on server for the first time or not.
Propert Page.IspostBack== true means your page has made a server visit. It is only a readOnly property i.e. we can only check that, cannot set this property accordingly.
AutoPostBack: It is property for .net controls to allow them to post the page to server and execute code-behind code at their events.
By Default,Button has this property set to true. For other controls like DropDownList,RadioButtonList etc., we have to set set it to true if we want to perform an action at their events like selectedIndexChanged etc.

How can you tell the application to look for assemblies at the locations other than its own install? 
Use the directive in the XML .config file for a given application. Make Your Homepage.

Introduction to Visual Basic DotNet(VB.Net)

Tuesday, October 7th, 2008

Visual Basic.NET is modeled on the .NET framework. Therefore, along with the features of earlier versions of Visual Basic, Visual Basic.NET also inherits various features of the .NET framework. In this section, you will look at some of the new features in Visual Basic.NET that were unavailable in earlier versions of Visual Basic.Visual Basic.NET supports implementation inheritance in contrast to the earlier versions of Visual Basic that supported interface inheritance. In other words, with earlier versions of Visual Basic, you can only implement interfaces.

When you implement an interface in Visual Basic 6.0, you need to implement all the methods of the interface. Additionally, you need to rewrite the code each time you implement the interface. On the other hand, Visual Basic.NET supports implementation inheritance. This implies that, while creating applications in Visual Basic.NET, you can derive a class from another class, known as the base class. The derived class inherits all the methods and properties of the base class. In the derived class, you can either use the existing code of the base class or override the existing code. Therefore, with the help of implementation inheritance, code can be reused. Although a class in Visual Basic.NET can implement multiple interfaces, it can inherit from only one class.

Visual Basic.NET provides constructors and destructors. Constructors are used to initialize objects. In contrast, destructors are used to release the memory and resources used by destroyed objects. In Visual Basic.NET, the Sub New procedure replaces the Class_Initialize event. Unlike the Class_Initialize event available in earlier versions of Visual Basic, the Sub New procedure is executed when an object of the class is created. In addition, you cannot call the Sub New procedure. The Sub New procedure is the first procedure to be executed in a class. In Visual Basic.NET, the Sub Finalize procedure is available instead of the Class_Terminate event. The Sub Finalize procedure is used to complete the tasks that must be performed when an object is destroyed. The Sub Finalize procedure is called automatically when an object is destroyed.

Garbage collection is another new feature in Visual Basic.NET. The .NET framework monitors allocated resources such as objects and variables. In addition, the .NET framework automatically releases memory for reuse by destroying objects that are no longer in use. In Visual Basic 6.0, if you set an object to Nothing, the object is destroyed. In contrast, when an object is set to Nothing in Visual Basic.NET, it still occupies memory and uses other resources. However, the object is marked for garbage collection. Similarly, when an object is not referenced for a long period of time, it is marked for garbage collection. In Visual Basic.NET, the garbage collector checks for the objects that are not currently in use by applications. When the garbage collector comes across an object that is marked for garbage collection, it releases the memory occupied by the object. The garbage collector automatically handles the memory allocated to managed resources. However, you need to manage the memory allocated to unmanaged resources.

In the .NET framework, you can use the GC class, the Sub Finalize procedure, and the IDisposable interface to perform garbage collection operations for unmanaged resources. The GC class is present in the System namespace. It provides various methods that enable you to control the system garbage collector. The Sub Finalize procedure, which is a member of the Object class, acts as the destructor in the .NET framework. You can override the Sub Finalize procedure in your applications.
However, the Sub Finalize procedure is not executed when your application is executed. The GC class calls the Sub Finalize procedure to release memory occupied by a destroyed object. Thus, implementing the Sub Finalize procedure is an implicit way of managing resources. However, the .NET framework also provides an explicit way of managing resources in the form of the IDisposable interface. The IDisposable interface includes the Dispose method. After implementing the IDisposable interface, you can override the Dispose method in your applications. In the Dispose method, you can release resources and close database connections.Unlike earlier versions of Visual Basic, Visual Basic.NET supports overloading.
Overloading enables you to define multiple procedures with the same name, where each procedure has a different set of arguments. In addition to procedures, you can also use overloading for constructors and properties in a class. You need to use the Overloads keyword for overloading procedures. Consider a scenario in which you need to create a procedure that displays the address of an employee. You should be able to view the address of the employee based on either the employee name or the employee code. In such a situation, you can use an overloaded procedure. You will create two procedures.
Each procedure will have the same name but different arguments. The first procedure will take the employee name as the argument, and the second takes the employee code as the argument.The .NET framework class library is organized into namespaces. A namespace is a collection of classes. Namespaces are used to logically group classes within an assembly. These namespaces are available in all the .NET languages, including Visual Basic.NET.
In Visual Basic.NET, you must use the Imports statement to access the classes in namespaces.
For example, to use the button control defined in the System.Windows.Forms namespace, you must include the following statement at the beginning of your program:

Imports System.Windows.Forms

After adding the Imports statement, you can use the following code to create a new button:

Dim MyButton as Button

If you do not include the Imports statement in the program, however, you would need to use the full reference path of the class to create a button. If you didn’t include the Imports statement, you would use the following code to create a button:

Dim MyButton as System.Windows.Forms.Button

In addition to using the namespaces available in Visual Basic.NET, you can also create your own namespaces.Visual Basic.NET supports multithreading. An application that supports multithreading can handle multiple tasks simultaneously. You can use multithreading to decrease the time taken by an application to respond to user interaction. To do this, you must ensure that a separate thread in the application handles user interaction.

Visual Basic.NET supports structured exception handling, which enables you to detect and remove errors at runtime. In Visual Basic.NET, you need to use

Try…Catch…Finally statements to create exception handlers.
Using Try…Catch…Finally statements, you can create robust and effective exception handlers to improve the performance of your application.