Yes. An interface can extend multiple interfaces, as shown here:

interface Maininterface extends inter1, inter2, inter3{  
  // methods
}

A single class can also implement multiple interfaces

interface A
{
    void test();
}

interface B 
{
    void test();
}

class C implements A, B
{
    @Override
    public void test() {

    }     
}

Single implementation works for both.

I will give you an example first:

public interface LoginAuth{
   public String encryptPassword(String pass);
   public void checkDBforUser();
}

Now suppose you have 3 databases in your application. Then each and every implementation for that database needs to define the above 2 methods:

public class DBMySQL implements LoginAuth{
          // Needs to implement both methods
}
public class DBOracle implements LoginAuth{
          // Needs to implement both methods
}
public class DBAbc implements LoginAuth{
          // Needs to implement both methods
}

But what if encryptPassword() is not database dependent, and it’s the same for each class? Then the above would not be a good approach.

Instead, consider this approach:

public abstract class LoginAuth{
   public String encryptPassword(String pass){
            // Implement the same default behavior here 
            // that is shared by all subclasses.
   }

   // Each subclass needs to provide their own implementation of this only:
   public abstract void checkDBforUser();
}

Now in each child class, we only need to implement one method – the method that is database dependent.

Technical Differences

  1. Implementing an interface consumes very little CPU, because it’s not a class, just a bunch of names, and therefore there is no expensive look-up to do. It’s great when it matters such as in embedded devices
  2. Abstract classes, unlike interfaces, are classes. They are more expensive to use because there is a look-up to do when you inherit from them.
  3. Abstract classes can have constants, members, method stubs (methods without a body) and defined methods, whereas interfaces can only have constants and methods stubs.
  4. Methods and members of an abstract class can be defined with any visibility, whereas all methods of an interface must be defined as public (they are defined public by default).
  5. When inheriting an abstract class, a concrete child class must define the abstract methods, whereas an an abstract class can extend another abstract class and abstract methods from the parent class don’t have to be defined.
  6. Similarly, an interface extending another interface is not responsible for implementing methods from the parent interface. This is because interfaces cannot define any implementation.
  7. A child class can only extend a single class (abstract or concrete), whereas an interface can extend or a class can implement multiple other interfaces.
  8. A child class can define abstract methods with the same or less restrictive visibility, whereas a class implementing an interface must define the methods with the exact same visibility (public).

Consider using abstract classes if :
You want to share code among several closely related classes.
You expect that classes that extend your abstract class have many common methods or fields, or require access modifiers other than public (such as protected and private).
You want to declare non-static or non-final fields.

Consider using interfaces if :

You expect that unrelated classes would implement your interface. For example,many unrelated objects can implement Serializable interface.
You want to specify the behaviour of a particular data type, but not concerned about who implements its behaviour.
You want to take advantage of multiple inheritance of type.

abstract class establishes “is a” relation with concrete classes. interface provides “has a” capability for classes.

You can define an abstract method to be protected, and hence not part of the public API of the class. However, that seems like an odd design.

Another thing – instance variables. You can have inheritable instance variables in the abstract class.

Abstract class Methods can be defined at various levels down the path.

In a 100% abstract class, you can also define non constant variables that can be herited. It is not possible with interfaces.

The one case where an “100% abstract class” may be advantageous over an interface is in places where API stability is a key concern.

If you write an API where other people are expected to implement your interface you have to stick to the interface. You can’t add any methods to the interface later on because that would break all clients (you would have to work around this by implement a second interface and let your code check againt the usage with instanceof checks and provide an fallback).

How to use interface Java

public class Main 
{
   public static void main(String args[])
   {
      BallAttributes objBallAttributes = new BallAttributes();
      RubberBall     objRubberBall     = new BallAttributes();
		
      objBallAttributes.bouncable();
      objRubberBall.moveable();
   }
}

class BallAttributes implements RubberBall, Movable 
{
    public void bouncable()
    {
      System.out.println("I am Bouncing");
    }	
    
    public void moveable()
    {
      System.out.println("I am Moving");
    }	
}

interface RubberBall 
{
    public void bouncable();
}

interface Movable 
{
    public void moveable();
}