26.02.2015 Views

DOT NET Interview Questions - DotNetSpider

DOT NET Interview Questions - DotNetSpider

DOT NET Interview Questions - DotNetSpider

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

√<br />

√<br />

Abstract class is designed to act as a base class (to be inherited by other classes).<br />

Abstract class is a design concept in program development and provides a<br />

base upon which other classes are built.<br />

Abstract classes are similar to interfaces. After declaring an abstract class, it<br />

cannot be instantiated on it's own, it must be inherited.<br />

√ In VB.<strong>NET</strong> abstract classes are created using “MustInherit” keyword.In C#<br />

we have “Abstract” keyword.<br />

√<br />

Abstract classes can have implementation or pure abstract methods which<br />

should be implemented in the child class.<br />

Note:- In order to understand the concept simple sample of add and multiply functionality<br />

is implemented in “WindowsAbstract” folder in CD.<br />

From interview point of view just saying using “MustInherit” keyword is more than enough<br />

to convince that you have used abstract classes.But to clear simple fundamental let’s try<br />

to understand the sample code.There are two classes one is “ClsAbstract” class and other<br />

is “ClsChild” class.”ClsAbstract” class is a abstract class as you can see the mustinherit<br />

keyword.It has one implemented method “Add” and other is abstract method which has<br />

to be implemented by child class “MultiplyNumber”.In the child class we inherit the<br />

abstract class and implement the multiplynumber function.<br />

Definitely this sample does not take out actually how things are implemented in live<br />

projects.Basically you put all your common functionalities or half implemented<br />

functionality in parent abstract class and later let child class define the full functionality<br />

of the abstract class.Example i always use abstract class with all my SET GET properties<br />

of object in abstract class and later make specialize classes for insert,update,delete for<br />

the corresponding entity object.<br />

Public MustInherit Class ClsAbstract<br />

‘ use the mustinherit class to declare the class as abstract<br />

Public Function Add(ByVal intnum1 As Integer, ByVal intnum2 As<br />

Integer) As Integer<br />

Return intnum1 + intnum2<br />

End Function<br />

‘ left this seconf function to be completed by the inheriting<br />

class<br />

Public MustOverride Function MultiplyNumber(ByVal intnum1 As<br />

Integer, ByVal intnum2 As Integer) As Integer<br />

End Class<br />

102<br />

* What type of environment you are looking for ?

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!