Interface vs abstract class
Interface:
In real world remote acts as a interface between person and tv.
It does not have implementation. It has only method declaration. It contains set of rules. To implement the rules we need class. By default all variables are public static final. We cannot create object for interface. As the vaiable is static We don’t have constructor have interface. It is used to achieve 100% abstraction.

• Definition: An interface is a reference type in Java, it is similar to a class, and it is a collection of abstract methods and static constants.
• Method Implementation: All methods in an interface are by default abstract and must be implemented by any class that implements the interface.From Java 8, interfaces can have default and static methods with concrete implementations.From Java 9, interfaces can also have private methods.
• Variables: Variables declared in an interface are by default public, static, and final (constants).

Abstract class:
Abstract class can have implementation and also abstract methods. It used to achieve 0 to 100% abstraction. We cannot able to create object for abstract class. But the abstract class can be extended and the using sub class object we can access abstract class methods.
When the sub class constructor is called through super() abstract class constructor is called.

  1. In Java, just like in C++ an instance of an abstract class cannot be created, we can have references to abstract class type though.
  2. Like C++, an abstract class can contain constructors in Java. And a constructor of an abstract class is called when an instance of an inherited class is created.
  3. In Java, we can have an abstract class without any abstract method. This allows us to create classes that cannot be instantiated but can only be inherited.
  4. Abstract classes can also have final methods (methods that cannot be overridden)
  5. For any abstract java class we are not allowed to create an object i.e., for an abstract class instantiation is not possible. If we try will get compilation error.
  6. Similar to the interface we can define static methods in an abstract class that can be called independently without an object.
  7. We can use the abstract keyword for declaring top-level classes (Outer class) as well as inner classes as abstract
  8. If a class contains at least one abstract method then compulsory that we should declare the class as abstract otherwise we will get a compile-time error ,If a class contains at least one abstract method then, implementation is not complete for that class, and hence it is not recommended to create an object so in order to restrict object creation for such partial classes we use abstract keyword.
  9. If the Child class is unable to provide implementation to all abstract methods of the Parent class then we should declare that Child class as abstract so that the next level Child class should provide implementation to the remaining abstract method.
  10. Definition: An abstract class is a class that cannot be instantiated directly (which means we can not create an object directly from an abstract class). An abstract class is like a blueprint for other classes.
  11. Method Implementation: An abstract class can contain both abstract methods (methods without an implementation) and concrete methods (methods with an implementation).
  12. Variables: Abstract classes can have member variables, including final, non-final, static, and non-static variables.
  13. Constructors: Abstract classes can have constructors, which can be used to initialize variables in the abstract class when it is instantiated by a subclass.

When to Use Class and Interface?
Use a Class when:
-Use a class when you need to represent a real-world entity with attributes (fields) and behaviors (methods).
-Use a class when you need to create objects that hold state and perform actions
-Classes are used for defining templates for objects with specific functionality and properties.
Use a Interface when:
-Use an interface when you need to define a contract for behavior that multiple classes can implement.
-Interface is ideal for achieving abstraction and multiple inheritance.