473,408 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Abstract class vs. interface

hello Guys I have a nice topic to discuss about, which always asked in every interview which is that...............
what is the difference between abstract class and interface, if we do same thing with abstract class as well as with interface then what is the difference?
Jun 30 '07 #1
4 1585
JosAH
11,448 Expert 8TB
hello Guys I have a nice topic to discuss about, which always asked in every interview which is that...............
what is the difference between abstract class and interface, if we do same thing with abstract class as well as with interface then what is the difference?
This topic has been discussed to death many many times. Google knows all
about it as well.

kind regards,

Jos
Jun 30 '07 #2
cygsoft
29
In abstract class there can be a non-abstract method with implementation could be present. Whereas in interface no method should be implemented.
Jun 30 '07 #3
This topic has been discussed to death many many times. Google knows all
about it as well.

kind regards,

Jos
Yes google knows about it but i cant find any simple example which clarify the difference to person like me(who is not very claver in programming).
kindly give me any simple example which shows such a functionality, which is only possible by abstract class and not possible by interface or vise-versa.

thanks.
Inam ur Rehman.
Jun 30 '07 #4
JosAH
11,448 Expert 8TB
Yes google knows about it but i cant find any simple example which clarify the difference to person like me(who is not very claver in programming).
kindly give me any simple example which shows such a functionality, which is only possible by abstract class and not possible by interface or vise-versa.

thanks.
Inam ur Rehman.
You have to start thinking in types; everything is a type. An instance of a type
can do things, possbily given instances of (other) types. A interface is a type
and an (abstract) class is a type plus an implementation of the things it can do.

If a class implements everything an interface said it can do, the class is a
concrete class; otherwise it must be abstract. Interfaces (which are pure types)
are also called 'contracts'. For a class, in order to obey that contract it must
implement everything the interface 'promises' that it can do.

If/when you start coding, remember this 'mantra':

Code to the interface (type), not the implementation (class).

kind regards,

Jos
Jun 30 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
10
by: Joe | last post by:
My question is more an OOD question. I know *how* to implement both abstract classes and interfaces. Here's my question - under what circumstacnes does one use an abstract class and under what...
9
by: Sean Kirkpatrick | last post by:
To my eye, there doesn't seem to be a whole lot of difference between the two of them from a functional point of view. Can someone give me a good explanation of why one vs the other? Sean
5
by: Tony Johansson | last post by:
Hello!! Assume you have an Interface called ITest with these three method declarations. interface ITest { void foo1(); void foo2(); void foo3(); }
7
by: jason | last post by:
In the microsoft starter kit Time Tracker application, the data access layer code consist of three cs files. DataAccessHelper.cs DataAcess.cs SQLDataAccessLayer.cs DataAcccessHelper appears...
0
by: mailforpr | last post by:
Hi. Let me introduce an iterator to you, the so-called "Abstract Iterator" I developed the other day. I actually have no idea if there's another "Abstract Iterator" out there, as I have never...
4
by: David Zha0 | last post by:
Hi, "when we call a virtual method, the runtime will check the instance who called the method and then choose the suitable override method, this may causes the performance drop down", is this...
52
by: Ben Voigt [C++ MVP] | last post by:
I get C:\Programming\LTM\devtools\UselessJunkForDissassembly\Class1.cs(360,27): error CS0535: 'UselessJunkForDissassembly.InvocableInternals' does not implement interface member...
6
by: Miguel Guedes | last post by:
Hello, I recently read an interview with Bjarne Stroustrup in which he says that pure abstract classes should *not* contain any data. However, I have found that at times situations are when it...
5
by: =?Utf-8?B?UmljaA==?= | last post by:
Greetings, I am actually a VB.Net guy, but I have worked somewhat with C++ and C#. I just want to ask about the relationship between Abstract Classes and Interfaces. My first question is if...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.