Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




QuestPond’s Interview Questions & Answers on .NET

What is Object Oriented Programming?

OOP is software designing technique where we think in terms of real world objects.

What is a Class and object?

Class is a blue print / template. Objects are instances of classes, in other words they bring life in class.  To use a class we need to create an object.

What are abstract classes?

Abstract class is a half defined parent class. The full implementation of abstract class is defined by the child classes.

For example below code snippet shows a simple abstract class / half defined class called “DatabaseCommon” and later the concrete classes i.e. “SQLServer” and “Oracle” inherit and define a complete implementation for the same.

To define an abstract class we need to use the abstract keyword.

public abstract class DatabaseCommon
{
}
public  class SQLServer : DatabaseCommon
{
}
public  class Oracle : DatabaseCommon
{
}

What are abstract methods?

Abstract classes can have abstract methods. Abstract methods when defined in a parent class have to be implemented in the child classes. If abstract methods are not implemented it will throw a error.

What is an Interface?

Interface is a contract that defines the signature of the functionality. It looks like a class but has no implementation. It has only empty definition of methods, functions, events, and indexer.

Interfaces provide forced implementation. For instance in the below code snippet we have created a simple interface called as “IDbCompulsory”. The below classes who implement interface “IDbCompulsory” has to provide implementation for “ExecSql”.

interface  IDbCompulsory
{
void ExecSql();
}
public  class SQLServer : IDbCompulsory
{
public void ExecSql()
{
// Here code for firing SQL Server SQL statements
// are written          
}
}
public  class Oracle : IDbCompulsory
{
public void ExecSql()
{
// Here code for firing Oracle SQL statements
// are written                      
}
}

See following video on implementing interfaces with same method names in C#: -


Click and see here for more step by step learning .NET.


Helpful Website Url
http://www.questpond.com/
Share this article   |    Print    |    Article read by 2649 times
Author:
Shivprasad koirala Koirala
I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small E-learning company in India. We are very much active in making training videos , writing books and corporate trainings. Do visit my site http://www.questpond.com for .NET, C# , design pattern , WCF , Silverlight , LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server training and Interview questions and answers
Related Articles:
Related Interview Questions: