Software Asp.Net C# interview Questions for freshers
Q. What is Abstract Class in C#?
A. If we don't want a class to be instantiated, define the class as abstract. An abstract class can have abstract and non abstract classes. If a method is defined as abstract, it must be implemented in derived class. For example, in the classes given below, method DriveType is defined as abstract.
abstract class Bus
{
public Bus()
{
Console.WriteLine("Base Class Bus ");
}
public abstract void DriveType();
}
class Ford : Bus
{
public void DriveType()
{
Console.WriteLine("Right Hand ");
}
}
Method DriveType get implemented in derived class.
Q.What is Sealed Classes in c# ?
A. If a class is defined as Sealed, it cannot be inherited in derived class. Example of a sealed class is given below
public sealed class Bus
{
public Bus()
{
Console.WriteLine("Base Class Bus ");
}
public void DriveType()
{
Console.WriteLine("Right Hand ");
}
}
Q. What is an Interface in C#?
A. An interface is similar to a class with method signatures. There wont be any implementation of the methods in an Interface.
Classes which implement interface should have an implementation of methods defined in the abstract class.
Q. What is a Destructor in C# in asp.net ?
A. Destructor is a special method that get invoked/called automatically whenever an object of a given class gets destroyed. Main idea behind using destructor is to free the memory used by the object.
Q. What is a Constructor in C# ?
A. Constructor is a special method that get invoked/called automatically, whenever an object of a given class gets instantiated. In our class car, constructor is defined as shown below
public Bus()
{
Console.WriteLine("Base Class Bus");
}
Q. Explain GridView control in ASP.NET ?
A. The GridView control displays the values of a data source in a table. Each column represents a field, while each row represents a record. The GridView control supports the following features:
Binding to data source controls, such as SqlDataSource.
Built-in sort capabilities.
Built-in update and delete capabilities.
Built-in paging capabilities.
Built-in row selection capabilities.
Programmatic access to the GridView object model to dynamically set properties, handle events, and so on.
Multiple key fields.
Multiple data fields for the hyperlink columns.
Customizable appearance through themes and styles.
Creating a GridView