.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> ASP.Net >> Post New Question Subscribe to Interview Questions

What is difference between interface inheritance and class inheritance?

Posted By :Shashi Ray     Posted Date :November 27, 2008    Points :10   Category :ASP.Net 
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.

You can also find related Interview Question to What is difference between interface inheritance and class inheritance?  below: 

What is the difference between interface and abstract class ?

  
a class may inherit several interfaces, a class may inherit only one abstract class (More...)

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.


Shashi Ray (More...)

what is the difference between a class and a interface?

  
You can instantiate a class but you cannot instantiate an interface,you can only offer the funtionality of that interface not the implementation. (More...)

What's the difference between an interface and abstract class?

  
In an interface class, all methods must be abstract. In an abstract class some methods can be concrete. In an interface class, no accessibility modifiers are allowed, which is ok in an abstract class. (More...)

Can we implement Multiple Inheritance by using Abstract Class?

  
No.
As the abstarct class can contain simple methods also, therefore it doesn't support Multiple Inheritance in DotNet. (More...)

What is implementation inheritance and interface inheritance?

  
. When a class is derived from another class in such a way that it will inherit all its members to its corresponding derived class, then it is implementation inheritance.

. When a class inherits only the signatures of the functions from its corresponding base class, then it is interface inheritance. (More...)

What's the difference between an interface and abstract class?

  
Abstract Class:

A class that cannot be instantiated. An abstract class is a class that must be inherited and have the methods overridden. An abstract class is essentially a blueprint for a class without any implementation.

Interface:

Interfaces like classes define a set of properties methods and events. But unlike classes interfaces do not provide implementation. They are implemented by classes and defined as separate entities from classes (More...)

Difference between Interface and abstract class

  
When we need the subclasses to must implement all the methods of base class the then we Interface.
Abstract class can also contain no-abstract methods (More...)

What's the difference between an interface and abstract class?

  
(1)In the interface all methods must be abstract.
(2)In the abstract class some methods can be concrete. (More...)

What is the difference between a Struct and a Class?

  
The struct type is suitable for representing lightweight objects such as Point, Rectangle, and Color. Although it is possible to represent a point as a class, a struct is more efficient in some scenarios. For example, if you declare an array of 1000 Point objects, you will allocate additional memory for referencing each object. In this case, the struct is less expensive.

When you create a struct object using the new operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the new operator. If you do not use new, the fields will remain unassigned and the object cannot be used until all of the fields are initialized.

It is an error to declare a default (parameterless) constructor for a struct. A default constructor is always provided to initialize the struct members to their default values.

It is an error to initialize an instance field in a struct.

There is no inheritance for structs as there is for classes. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Structs, however, inherit from the base class Object. A struct can implement interfaces, and it does that exactly as classes do.

A struct is a value type, while a class is a reference type. (More...)

Does C# support multiple inheritance?

  
No

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 (More...)

What's the difference between the Debug class and Trace class?

  
Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds. (More...)

What is the difference between a struct and a class in C#?

  
Strut is a value type.
Class is a reference type.

Class comes in OOPS. But strut does not come in OOPS.
Strut uses less memory than class at run time. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

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 Interview Question 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    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend