Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6771095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:23:29+00:00 2026-05-26T15:23:29+00:00

Abstract classes and interfaces play very a important role in Java and they have

  • 0

Abstract classes and interfaces play very a important role in Java and they have their own importance in certain situations. They possess certain special characteristics. There are some observable differences between them. Let me describe some a few of them.


One of the major differences between an interface and an abstract class is that an abstract class can never be instantiated, an interface however can.

Both of them can never be declared as final obviously, because they are to be inherited by some other non-abstract class(es).

Both of them can never have static methods. Neither concrete nor abstract (abstract static methods indeed and in fact, don’t exist at all).

An interface can never never have concrete methods (a method with it’s actual implementation), an abstract class however can have concrete methods too.

An interface can not have constructors, an abstract class can however can have.


Two obvious questions are likely to arise here.

An abstract class can never be instantiated because it is by nature, not a fully implemented class and it’s full implementation requires it to be inherited by some other non-abstract class(es). If it is so then, an abstract class should not have a constructor of it’s own because a constructor implicitly returns an object of it’s own class and an abstract class by itself can not be instantiated hence, it should not be able to have a constructor of it’s own.

An interface somewhat looks better and more appropriate to use than an abstract class, since it imposes less restrictions than what those are imposed by an abstract class. In which very specific situations, an interface is useful and in which very specific situations, an abstract class is appropriate? Hope! the boldface letters would be taken into much consideration.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:23:30+00:00Added an answer on May 26, 2026 at 3:23 pm

    First off, you’re factually wrong in a few places:

    • One of the major differences between an interface and an abstract class is that an abstract class can never be instantiated, an interface however can.

    Wrong. An abstract and interface can both be instantiated anonymously.

    • Both of them can never be declared as final obviously, because they are to be inherited by some other non-abstract class(es).

    True, although I personally see no reason why interfaces couldn’t have been able to be final so they couldn’t be extended, but that’s just me. I see why they made the decision they did.

    • Both of them can never have static methods. Neither concrete nor abstract (abstract static methods indeed and in fact, don’t exist at all).

    Abstract classes can have static methods; sorry!

    • An interface can never never have concrete methods (a method with it’s actual implementation), an abstract class however can have concrete methods too.

    Yes, that’s one of the the primary differences between them.

    • An interface can not have constructors, an abstract class can however can have.

    Yes, that’s true.

    Now, let’s move on to your questions:

    Your first paragraph doesn’t have a question in it. What was the question there? If it was “Why allow abstract classes to have constructors if you can’t instantiate them?” the answer is so child classes can use it. Here’s an example

    abstract class Parent {
        String name;
        int id;
        public Parent(String n, int i) { name = n; id = i; }
    }
    
    class Child extends Parent {
        float foo;
        public Child(String n, int i, float f) {
            super(n,i);
            foo = f;
        }
    }
    
    // later
    Parent p = new Parent("bob",12); // error
    Child c = new Child("bob",12); // fine!
    

    Your second paragraph has a question but is malformed. I think you’re simply missing an ‘is’ in there… 🙂 The answer to it is as follows:

    You use an interface when you want to define a contract. Here’s a very specific example:

    public interface Set<E> {
        int size(); // determine size of the set
        boolean isEmpty(); // determine if the set is empty or not
        void add(E data); // add to the set
        boolean remove(E data); // remove from the set
        boolean contains(E data); // determine if set holds something
    }
    

    Four common methods to all sets.

    You use an abstract class when you want to define SOME of the behavior, but still have the contract

    public abstract class AbstractSet<E> implements Set<E> {
       // we define the implementation for isEmpty by saying it means
       // size is 0
       public boolean isEmpty() { return this.size() == 0; }
       // let all the other methods be determined by the implementer
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So my question is, why to use interfaces or abstract classes? Why are they
In java document, it is said : Unlike interfaces, abstract classes can contain fields
Possible Duplicate: Use of Java [Interfaces / Abstract classes] What's the benefit of interfaces
I have question connected with interfaces and abstract classes. I'll give to you simple
I'm working through an exercise sheet regarding interfaces, generics and abstract classes in Java.
I'm creating interfaces and abstract classes that represent a messaging framework for short text-based
In C#, when should you use interfaces and when should you use abstract classes?
Is there a runtime performance penalty when using interfaces (abstract base classes) in C++?
Consider the following example. I have an interface MyInterface, and then two abstract classes
I have 3 abstract classes (Customer, Tender, Site). For Customer has inherited class such

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.