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

How can I execute a Java program?
Through command-line 1.compile the code using javac filename.java 2. Finally run the code using java filename here filename is classname. If u use eclipse then right click the java code n select run as java application .
Suresh
0 0
5
I am looking for live project trainer for Java j2ee near Hinjewadi ph 3 or near Bavdhan. Thanks
I am a passoniate software enginner and a professional trainer. I can provide support for your live project.
Richa
What are the requirements of learning Java? How long it takes to learn java and what is the fee structure?
Core java is main to learn, if you join my classes it takes one month to become master.
Ruuchi
What are the necessary qualifications needed for a Java tutor?
1. Knowledge 2. Good education background 3. Experience in teaching 4. Applications and projects that he has himself worked on 5. The zeal to help students
Darshan
0 0
7

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

Ask a Question

Related Lessons

Comparable vs Comparator
java.lang.Comparable java.util.Comparator For comparing some other object with its own object. Ex. I am comparing myself to some other employee. Method signature is: int compareTo (T object). For...


Core Java
Introduction: An Object Oriented Programming Language consists of Objects. There are object oriented programming languages like Smalltalk, C++. Each and every OOP language has some underlying disadvantages....

Mastering in Java Programming
Core java topics What is Java?Execution Model Of JavaBytecodeHow to Get Java?A First Java ProgramCompiling and Interpreting ApplicationsThe JDK Directory StructureUsing Eclipse Data types and Variables What...

Easy way to remember Java keyword.
ACCESS MODIFIER ACCESS SPECIFIER abstract, assert, const, final, native, static, strictfp, super, synchronized, this, transient, void, volatile public, private, protected, default DATA...

Rohit Deshbhratar

1 0
0

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