473,383 Members | 1,739 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,383 software developers and data experts.

Difference between Interfaces and Abstract Class

38
Both of them provides abstraction and we have to give their implementation in their child classes so what's exactly is the difference between them and also please suggest me some scenario where i can use them.
Jan 2 '16 #1

✓ answered by Vikas Rana

When we declare any method inside the Interface it is implicitly abstract in other words we can say that you cannot give a definition of a method inside the interface because it would be an error BUT this is not the case with Abstract Classes, it can and cannot contain abstract methods.
Note - There should be at least one abstract method in an Abstract Class

2 3074
When we declare any method inside the Interface it is implicitly abstract in other words we can say that you cannot give a definition of a method inside the interface because it would be an error BUT this is not the case with Abstract Classes, it can and cannot contain abstract methods.
Note - There should be at least one abstract method in an Abstract Class
Jan 2 '16 #2
Sherin
77 64KB
Abstract Class

An abstract class may contain concrete method.
To use an abstract class, you need to inherit it. Provide body to (override) the abstract methods if there are any.
Members of an abstract class can be public, private, protected or default.

Example:

Expand|Select|Wrap|Line Numbers
  1. public abstract class Shape{
  2. public abstract void draw();
  3. }
  4.  
Interface

All the methods of an interface are abstract.
To use an interface you need to implement the interface and provide body to (override) all the abstract methods of it.
All the members of the interface are public by default.

Example:
Expand|Select|Wrap|Line Numbers
  1. public interface Drawable{
  2. void draw();
  3. }
  4.  
May 29 '20 #3

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

Similar topics

1
by: G. Smith Q news | last post by:
What is the difference between an abstract class and an Interface. As a novice, they both seem to serve the same purpose?
5
by: Michael McCarthy | last post by:
I want to develop plugin support for a system.montitor module I am working on. A lot of the modules will do mostly interop stuff for an older system, but I want to use it myself as well to monitor...
18
by: Bradley | last post by:
I'm trying to determine if there's a general rule for when an Interface should used vs. an Abstract Class. Is there any design advantage to using one or the other? Brad
4
by: skishorev | last post by:
and what is object delagation, and how it can implemented?
4
by: N.RATNAKAR | last post by:
hai, what is abstract class and abstract method
3
by: Salman | last post by:
One one please tell me whats the difference between ABSTRACT Class and INTERFACE Class in c++. If you can explain me using examples, that would be more good for me.
4
by: Inam ur Rehman | last post by:
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...
9
by: msbs1984 | last post by:
Difference Between Interface and Abstract Class?
0
by: temptest | last post by:
An abstract method has no implementation. Its implementation logic is provided instead by classes that derive from it. We use an abstract class to create a base template for derived classes. using...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.