Win Surprise Gifts!!!
Top 5 Contributors of the Month
Post New Question
Subscribe to Interview Questions
Can we implement Multiple Inheritance by using Abstract Class?
Posted By :
Posted Date :
November 27, 2010
As the abstarct class can contain simple methods also, therefore it doesn't support Multiple Inheritance in DotNet.
You can also find related Interview Question to
Can we implement Multiple Inheritance by using Abstract Class?
What is the difference between interface and abstract class ?
a class may inherit several interfaces, a class may inherit only one abstract class
Does C# support multiple inheritance?
C# does not support multiple inheritance. A class can inherit from maximum one base class, although it can implement any number of interfaces. Like Java, C# does not support multiple inheritance, meaning that classes cannot inherit from more than one class
What is difference between interface inheritance and class inheritance?
We can only inherit from one class but multiple interfaces. In addition, an interface does not contain any implementation it just contains a series of signatures.
What is difference between abstract class and an interface?
An Abstract class is a class with some common/certain implementations and defines abstraction for other services which are implemented in its concrete sub classes, whereas interface only have method declaration with zero implementations. An abstract class and Interface both have method only but not have body of method. The difference between Abstract class and An Interface is that if u call Abstract class then u have to call all method of that particular Abstract class but if u call an Interface then it is not necessary that u call all method of that particular interface. 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, it is a kind of contract that forces all the subclasses to carry on the same hierarchies or standards.
An interface is not a class. It is an entity that is defined by the word Interface. An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body. As one of the similarities to Abstract class, it is a contract that is used to define hierarchies for all subclasses or it defines specific set of methods and their arguments. The main difference between them is that a class can implement more than one interface but can only inherit from one abstract class. Since C# doesn't support multiple inheritance, interfaces are used to implement multiple inheritance.
When do you have to declare a class as abstract?
1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.
2. When at least one of the methods in the class is abstract.
How would you implement inheritance using VB.NET/C#?
When we set out to implement a class using inheritance, we must first start with an existing class from which we will derive our new subclass. This existing class, or base class, may be part of the .NET system class library framework, it may be part of some other application or .NET assembly, or we may create it as part of our existing application. Once we have a base class, we can then implement one or more subclasses based on that base class. Each of our subclasses will automatically have all of the methods, properties, and events of that base class ? including the implementation behind each method, property, and event. Our subclass can add new methods, properties, and events of its own - extending the original interface with new functionality. Additionally, a subclass can replace the methods and properties of the base class with its own new implementation - effectively overriding the original behavior and replacing it with new behaviors. Essentially inheritance is a way of merging functionality from an existing class into our new subclass. Inheritance also defines rules for how these methods, properties, and events can be merged.
To define abstract class in VB which keyword is used?
MustInherit keyword is used to create an abstract class in VB.
Tell me one reason for dotnet doesn't have multiple inheritance
To avoid ambiguity and deadlocks
Explain About Abstract Class?
An abstract class means that the class is intended to be used as a base class.
Note the following features of abstract classes:
.An abstract class cannot be instantiated.
.An abstract class may contain abstract methods and properties.
.A non-abstract class that derives from an abstract class must implement all inherited abstract methods and properties. (if any).
.An abstract class must provide implementation for all interface members
can we impliment multiple inheritance by using interfaces in C#.net?
yes we can implement:
Inheritance Usage Example:
Here is a syntax example for using Implementation Inheritance.
derivedClass is derived from baseClass.
Interface Inheritance example:
private Class derivedClass:baseClass , InterfaceX , InterfaceY ....
Which is Default inheritance class in .NET programing
suppose two interfaces have same method, so how will you implement these methods in derive class?
by using interface name
Explain why java doesn't support multiple inheritance.
Java does not support multiple inheritances. To avoid ambiguity problem - Diamonds of Death - and complexity of multiple inheritance.
The Diamond of Death is a problem without clarity. The Diamond problem is:
Two classes Two and Three inherit from class One. Class Four inherits from both Two and Three. When a method in Four invokes a method that is defined in One, and Two and Three have overridden that method in different way, the ambiguity and complexity occurs - through which class does it inherits: class Two or class Three?
Like wise if it is encouraged to have more than two classes to inherit, the ambiguity raises which leads to future conflict of applications.
Name the classes that derive from the abstract System.Windows.Shapes.Shape class in WPF?
Quick Links For Interview Questions Categories:
Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.
So, Start looking our
section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.
Hall of Fame
Terms of Service
Tell A Friend