UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

What are the difference between abstract class and Interface?

Asked by Last Modified  

19 Answers

Learn Java

Follow 0
Answer

Please enter your answer

Abstraction : Hiding unnecessary details of object and shows only essential features of Object to communicate. abstract class : partially defined Object interface :Complete specification of Object class : Complete definition of Object
Comments

Tutor - Maths and computer science

An interface differs from an abstract class because an interface is not a class. An interface is essentially a type that can be satisfied by any class that implements the interface. Any class that implements an interface must satisfy 2 conditions: It must have the phrase "implements Interface_Name"...
read more
An interface differs from an abstract class because an interface is not a class. An interface is essentially a type that can be satisfied by any class that implements the interface. Any class that implements an interface must satisfy 2 conditions: It must have the phrase "implements Interface_Name" at the beginning of the class definiton. It must implement all of the method headings listed in the interface definition. 1. Abstract classes are meant to be inherited from, and when one class inherits from another it means that there is a strong relationship between the 2 classes. For instance, if we have an abstract base class called "Canine", any deriving class should be an animal that belongs to the Canine family (like a Dog or a Wolf). The reason we use the word "should" is because it is up to the Java developer to ensure that relationship is maintained. With an interface on the other hand, the relationship between the interface itself and the class implementing the interface is not necessarily strong. For example, if we have a class called "House", that class could also implement an interface called "AirConditioning". Having air conditioning not really an essential part of a House (although some may argue that point), and the relationship is not as strong as, say, the relationship between a “TownHouse” class and the "House" class or the relationship between an “Apartment” class that derives from a “House” class. Because a TownHouse is a type of House, that relationship is very strong, and would be more appropriately defined through inheritance instead of interfaces. So, we can summarize this first point by saying that an abstract class would be more appropriate when there is a strong relationship between the abstract class and the classes that will derive from it. Again, this is because an abstract class is very closely linked to inheritance, which implies a strong relationship. But, with interfaces there need not be a strong relationship between the interface and the classes that implement the interface. read less
Comments

Abstract and Interface both are used for inheritence. :) Abtract classes are used in IS-A relationship. Interfaces can be used in both IS-A and HAS-A relationship. Abstract classes are used for Specialization Example: class RentedHouse extends House{} // House is abstract, class Apple extends...
read more
Abstract and Interface both are used for inheritence. :) Abtract classes are used in IS-A relationship. Interfaces can be used in both IS-A and HAS-A relationship. Abstract classes are used for Specialization Example: class RentedHouse extends House{} // House is abstract, class Apple extends Fruit{} // Fruit is abstract class Dog extends Animal{} // Animal is abstract Interfaces are used for Generalization. Example: interface Switch{} // with on and off method class DVDPlayer implements Switch{} // class has to give the implementation of switch. class RentedHouse implements Switch{} // Hope I made it clear. read less
Comments

Technology Trainer(C, C++, Java , DS , DBMS etc)

Abstract class can have both abstract methods as well as non abstract , whereas interface can have only abstract methods.
Comments

Java/J2EE/SFDC Corporate Trainer

Abstract class is the class which is partially implemented means it contains some defined methods and undefined methods but in case of interface only we have undefined methods and final initilized variables means interface is a specification implemented in a class. In general we use interfaces for module...
read more
Abstract class is the class which is partially implemented means it contains some defined methods and undefined methods but in case of interface only we have undefined methods and final initilized variables means interface is a specification implemented in a class. In general we use interfaces for module collaboration in project scenario. read less
Comments

IT Professional Trainer with 15 years of experience in IT Industry

Interfaces are rules (Rules because you must give an implementation to them and that you can't ignore or avoid, so that are imposed like rules) which works as a common understanding document among the various teams in software development. Interfaces give the idea what is to be done but not how it...
read more
Interfaces are rules (Rules because you must give an implementation to them and that you can't ignore or avoid, so that are imposed like rules) which works as a common understanding document among the various teams in software development. Interfaces give the idea what is to be done but not how it will be done. So implementation completely depends on developer by following the given rules(Means given signature of methods). Abstract classes may contain only abstract declarations or only concrete implementations or mixed. Abstract declarations are like rules to be followed and concrete implementations are like guidelines(You can use that as it is or you can ignore it by overriding and giving your own choice implementation to it). Moreover which methods with same signature may change the behaviour in different context are provided as interface declarations as rules to implement accordingly in different contexts read less
Comments

Software Trainer

Basic Difference Abstract Class:- 1. Abstract class can contain abstract as well as non abstract methods. 2. In abstract class constructor also possible. 3. In Abstract class methods must be declared as public. Interface:- basically used for multiple inheritance. 1. Interface can contains...
read more
Basic Difference Abstract Class:- 1. Abstract class can contain abstract as well as non abstract methods. 2. In abstract class constructor also possible. 3. In Abstract class methods must be declared as public. Interface:- basically used for multiple inheritance. 1. Interface can contains only abstract methods. 2. In interface constructor not possible. 3. No need to mention access specifiers(public, private...) because all method by default public. read less
Comments

I have 8+ yrs of industry working experience in PHP, MySQL, Javascript, JQuery, Ajax

Here a couple of things to know about each one. 1. Methods in abstract classes can be defined abstract or just a regular method. If a method is abstract, then that method must be defined in the class that extends it. In interfaces, ALL methods are abstract, therefore all methods must be defined in the...
read more
Here a couple of things to know about each one. 1. Methods in abstract classes can be defined abstract or just a regular method. If a method is abstract, then that method must be defined in the class that extends it. In interfaces, ALL methods are abstract, therefore all methods must be defined in the class that implements them. 2. You’re allowed to define your methods as public, private, or protected in abstract classes. In interfaces, ALL methods MUST be public. 3. In abstract classes, you’re allowed to create methods and properties with values and concrete code in them as long as they’re not defined as abstract. Interfaces CAN NOT contain properties and methods CAN NOT have a body. 4. A class can only extend 1 abstract class, but a class can implement an infinite amount of interfaces even if the interfaces don’t relate to one another. class Cookie implements Recipe, Business 5. You have an option to override methods in an abstract class, but you MUST override ALL methods in an interface. Interfaces are a bit more stricter than abstract classes. Interfaces are meant to be used just as a template or empty shell for other classes to follow a certain logic. Abstract classes are lenient and can contain some helpful methods and properties for any class that extends it. read less
Comments

I am best in java and J2ee because i worked in small company.

Abstract class not supported the multiple inheritance in java and this problem solve by interface using implements keywords.
Comments

I am best in java and J2ee because i worked in small company.

In interface all variable are public final static ,all method are public abstract and all inner class are static automatically by jvm but in abstract class this type of property not exists.
Comments

View 17 more Answers

Related Questions

Is Java a compiler or Interpreter?
Java is a programming language and computing platform first released by Sun Microsystems in 1995. A Java compiler is a compiler for the Java programming language. A JVM interprets bytecode and...
Dr Rakesh
Is JAVA training only for technical students or a non-technical student also may join?
Any Body can Learn Programming Language.It All depends upon the learning of basics and all.Basics actually makes the thing different.
Vikrant
0 0
6
What is the difference between Java and Advanced Java?
Java = Core + Advance(Servlets, JSPs & EJB)
Anu
What are different IDEs available to write programs?
There are many IDE for programming like TurboC++,Dev C++ for C and C++ programming. Eclipse,Notepad++,Dreamweaver for HTML,PHP,JAVA,ASP etc languages.
Meraj
0 0
5
What is the general syllabus covered in core Java training from any institution?
you can check the syallbus on http://felix-its.com/java-training-pune/
Shiv Kohli
0 0
5

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Fractional Knapsack
Algorithm - Fractional Knapsack import java.util.Scanner; public class Knapsack01 { public static void main(String args) { Scanner scan = new Scanner(System.in); int...

Java Interview Questions & Answers
Java Interview Questions have been designed especially to get you acquainted with the nature of questions you may encounter during your interview for the subject of Java Programming Language. As per my...

Java : Compile-time Versus Runtime optimization
While designing and development, one should think in terms of compile-time and run-time.It helps in understanding language basics in a better way.Let's understand this with a question below : What...
S

Java: A Quick Overview
Not purely Object Oriented: It doesn't support multiple inheritence, it supports primitive data types and static members. Doesn’t support multiple inheritance: Reason is diamond problem i.e.,...

What is a Programming Language
What is a Language? Language is a communication system of human. What is a programming Language? A programming Language is a formal constructed language design to communicate...

Recommended Articles

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

Designed in a flexible and user-friendly demeanor, Java is the most commonly used programming language for the creation of web applications and platform. It allows developers to “write once, run anywhere” (WORA). It is general-purpose, a high-level programming language developed by Sun Microsystem. Initially known as an...

Read full article >

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more