abstract class in Java

In Java, a class is made abstract by using abstract keyword.
An abstract class may contain any number of methods including zero. The methods can be abstract or concrete. Abstract methods may not appear in a class that is not abstract. The first concrete subclass of an abstract class is required to implement all abstract methods that were not implemented by a superclass.
Abstract Class Definition Rules:
* Abstract classes cannot be instantiated directly.
* Abstract classes may be defined with any number, including zero, of abstract and non-abstract methods.
* Abstract classes may not be marked as private or final.
* An abstract class that extends another abstract class inherits all of its abstract methods as its own abstract methods.
* The first concrete class that extends an abstract class must provide an implementation for all of the inherited abstract methods.

you can declare abstract class without defining an abstract method in it. Once you declare a class abstract it indicates that the class is incomplete and, you cannot instantiate it. Hence, if you want to prevent instantiation of a class directly you can declare it abstract.
```
abstract class Animal {
  public abstract void sound();
}

class Pig extends Animal {
  public void sound() {
    System.out.println("The pig says: wee wee");
  }
}

class Main {
  public static void main(String[] args) {
    Pig pig = new Pig(); 
    pig.sound();
  }
}
```

<b>Interface vs Abstract Class</b>
Difference | Abstract class | Interface
----- | ----- | -----
Type of methods | Abstract class can have abstract and non-abstract methods. | Interface can have only abstract methods. From Java 8, it can have default and static methods also.
Final Variables | Abstract class may contain non-final variables. | Variables declared in a Java interface are by default final. 
Type of variables | Abstract class can have final, non-final, static and non-static variables. | Interface has only static and final variables.
Implementation | Abstract class can provide the implementation of interface. | Interface can’t provide the implementation of abstract class.
Inheritance vs Abstraction | Abstract class can be extended using keyword “extends”. | Interface can be implemented using keyword “implements”  
Multiple implementation | Abstract class can extend another Java class and implement multiple Java interfaces.| Interface can extend multiple interfaces only 
Accessibility of Data Members | Abstract class can have class members like private, protected, etc. | Members of a Java interface are public by default