CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.




Get it now !!
Send your Resume to 6000 Companies

Search Interview Questions

Question: What is an abstract class?

Answer: The abstract modifier can be used with classes, methods, properties, indexers, and events.

Use the abstract modifier in a class declaration to indicate that a class is intended only to be a base class of other classes.

Abstract classes have the following features:

An abstract class cannot be instantiated.
An abstract class may contain abstract methods and accessors.
It is not possible to modify an abstract class with the sealed modifier, which means that the class cannot be inherited.
A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors.
Use the abstract modifier in a method or property declaration to indicate that the method or property does not contain implementation.

Abstract methods have the following features:

An abstract method is implicitly a virtual method.
Abstract method declarations are only permitted in abstract classes.
Because an abstract method declaration provides no actual implementation, there is no method body; the method declaration simply ends with a semicolon and there are no braces ({ }) following the signature. For example:
public abstract void MyMethod();



Category C# Interview Questions & Answers - Exam Mode / Learning Mode
Rating (0.2) By 7326 users
Added on 7/28/2011
Views 61808
Rate it!
Question: What is an abstract class?


Answer:

The abstract modifier can be used with classes, methods, properties, indexers, and events.

Use the abstract modifier in a class declaration to indicate that a class is intended only to be a base class of other classes.

Abstract classes have the following features:

An abstract class cannot be instantiated.
An abstract class may contain abstract methods and accessors.
It is not possible to modify an abstract class with the sealed modifier, which means that the class cannot be inherited.
A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors.
Use the abstract modifier in a method or property declaration to indicate that the method or property does not contain implementation.

Abstract methods have the following features:

An abstract method is implicitly a virtual method.
Abstract method declarations are only permitted in abstract classes.
Because an abstract method declaration provides no actual implementation, there is no method body; the method declaration simply ends with a semicolon and there are no braces ({ }) following the signature. For example:
public abstract void MyMethod(); Source: CoolInterview.com


abstract class is a prototype of a class. it is used to provide partial
class implementation. abstract class contain abstract method which can be implemented by derived class.
some rules for abstract class are following-:
1) an object of an abstract class can never be created.
2)you can not declare an abstract method outside the abstract class.
3)can not be declared sealed. Source: CoolInterview.com

Answered by: ritesh | Date: | Contact ritesh Contact ritesh

Abstract is a keyword.

Whenever a class is not providing full information then that class is called as Abstract Class.

A method without body is called as Abstract Class.

When a class contains atleast one abstract method also, then that class must be declared as Abstract Class.

Abstract method is also called as Rules.

Abstract method must be overrided in the derived classes.

Abstract class provides a set of rules(abstract methods) which must be followed (overrided) in the derived classes.

Abstract classes are not instantiatable(ie. object cannot be created) but a reference can be created.
Ex:- Test t = new Test; //object
Area a; // reference

Object contains its own memory but reference does not contain own memory.

Reference works based on child class memory.



Source: CoolInterview.com

Answered by: Aaber Osmani | Date: 11/25/2007 | Contact Aaber Osmani Contact Aaber Osmani

The abstract modifier can be used with classes, methods, properties, indexers, and events.
An abstract class cannot be instantiated.
An abstract class may contain abstract methods and accessors.
Abstract class is a prototype of a class. it is used to provide partial class implementation. abstract class contain abstract method which can be implemented by derived class.

Source: CoolInterview.com

Answered by: piyush | Date: 12/10/2007 | Contact piyush Contact piyush

abstract class is similar to classes in many cases.

but it only declares properties and members and leaves the implementation on the child classes.

except this these classes have following features :

1-you cannot instantiate abstract classes.
2-you can inherit any child class only form one abstract class.
this is a wrong syntax :
[child class:abstract1:abstract2 ]
this is correct syntax :
[ child class:abstract1]

3- abstract methods can be declared only in abstract classes. Source: CoolInterview.com

Answered by: ritesh | Date: 7/8/2008 | Contact ritesh Contact ritesh

abstract class is a special base class that consist of abstract class member.

All the class member derived directly from abstract class must implement all the abstract function and properties. Source: CoolInterview.com

Answered by: venkatesan | Date: 1/31/2009 | Contact venkatesan Contact venkatesan

"abstract" is a keyword to declare the abstract classes. Below is the syntax
abstract Class A
{

}

In abstract class declaration is provided but not Implementation

If one or more methods declared as abstract then the class should classify as "abstract' and you cannot insantiate the abstract classes. if a class which is inherting the abstract class then it should override all the abstract methods of base class in derived class. If the Inherted class is not overriding the abstract methods in derived class then the that class should be classify as abstract

A abstract method will have all the features of Concrete class like constructos and it will have abstract methods which concrete class doesnot

abstract Class CParent
{
Public abstract Void Foo()
{
console.writeline("Foo in Parentclass");
}
}

Class CChild:CParent
{

public override void Foo()
{
Console.WriteLine("Foo in child class");
}
} Source: CoolInterview.com

Answered by: Nageswara Rao | Date: 8/13/2009 | Contact Nageswara Rao Contact Nageswara Rao


Abstract class is a special kind of class which cannot be instantiated. Instantiated means we can not create any object at that class. We will create only abstract methods and concrete methods.
Abstract methods can not have body where as concrete method has body that means implementation.
We can call these methods in another class and implement the code what ever we want.

E.g.:-
Abstract class shape
{
Abstract void sides ();
}
Class line: shape
{
Public void sides ()
{
Console. Write (?one side?);
}}
Class triangle: shape
{
Public void sides ()
{
Console. Write (?three sides?);
}}
Class square: shape
{
Public void sides ()
{
Console. Write (?four sides?);
}}
Class side
{
Static void main ()
{
line l = new line ();
triangle t = new triangle ();
square s = new square();
l.sides ();
t.sides ();
s.sides ();
}
}
Source: CoolInterview.com

Answered by: sravan kumar | Date: 8/18/2009 | Contact sravan kumar Contact sravan kumar

An abstract class is a special kind of class that cannot be instantiated. So the question is why we need a class that cannot be instantiated? An abstract class is only to be sub-classed (inherited from). In other words, it only allows other classes to inherit from it but cannot be instantiated. The advantage is that it enforces certain hierarchies for all the subclasses. In simple words,an Abstract class superclass is a conceptual class does not exist in the real word, but acts as a base from which other class inherit perporties behavior Source: CoolInterview.com

Answered by: ramani | Date: 12/7/2009 | Contact ramani Contact ramani

A class which is not giving full functionality as per requirements then that class need to be declared as 'abstract class' Source: CoolInterview.com

Answered by: sudha | Date: 3/22/2010 | Contact sudha Contact sudha


If you have the better answer, then send it to us. We will display your answer after the approval

Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.

Post your answer here

Inform me about updated answers to this question.
Related Questions
View Answer
What does the keyword virtual mean in the method definition?

View Answer
How's method overriding different from overloading?

View Answer
What's the top .NET class that everything is derived from?

View Answer
Describe the accessibility modifier protected internal.

View Answer
Are private class-level variables inherited?

View Answer
When you inherit a protected class-level variable? Who is it available to?

View Answer
Does C# support multiple inheritance?

View Answer
How do you inherit from a class in C#?

View Answer
What's the implicit name of the parameter that gets passed into the class' set method?

View Answer
Is it mandatory to implement all the methods which are there in abstract class if we inherit that abstract class..?

View Answer


What is the difference between const and static read-only?



View Answer
How to fill datalist usinf XML file and how to bind it,code behind language is c#

View Answer
WHAT IS THE ADVANTAGE OF SERIALIZATION?

View Answer
How we hand sql exceptions? What is the class that handles SqlServer exceptions?

View Answer
What is indexer? where it is used plz explain

View Answer
can we inherit the java class in C# class,how?

View Answer
We declare an integer variable 'x' in C# as

View Answer
A code block in C# is enclosed between

View Answer
To read user input from the console, the following statement is used

View Answer
The following is a correct call to the Main() function

View Answer

Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

View All C# Interview Questions & Answers - Exam Mode / Learning Mode




India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0.046875 Seconds