There are total 6 types of classes in Java

1). Concrete class


A concrete class is a normal class that does not extend any abstract class, parent class, and also not implemented any interface. It has all methods of itself. In general, for any small programs, we use a concrete class and it is very simple.

Below are the example of concrete class:

public class Main {
static int multiply(int a, int b) {
return a * b;
}
public static void main(String args[]) {
int p = multiply(5, 6);
System.out.println("Multipliaction of two numbers = " + p);
}
}

2). Abstract class

An abstract class is a class that is declared with an abstract keyword. This means any class which starts with abstract keywords is knows as abstract class. An abstract class can have zero or more abstract methods. The abstract classes are basically incomplete classes and it doesn’t work independently. Any concrete class should extend the abstract classes to make them in use.

abstract class Animal {
public abstract void sound();
}
public class Main extends Animal {
public void sound() {
System.out.println("Meww");
}
public static void main(String args[]) {
Animal a = new Main();
a.sound();
}
}

3). Final class

Final class with the final keyword it means when we declare any class with final keywords is known as Final class. If we want to protect the class so that no other class can extend it then we use the final keyword with class.

final class FinalClass {
void show() {
System.out.print("This is show() method of FinalClass.");
}
}
class DerivedClass extends FinalClass {
void show() {
System.out.print("This is show() method of DerivedClass.");
}
}
public class Main{
public static void main(String[] arg) {
DerivedClass d = new DerivedClass();
d.show();
}
}

4). POJO class


POJO class is a very simple class that has no logic. Pojo class only contains private variables and their setter and getter methods. This getter and setter are used to access these private variables from the other class. The full form of POJO class is (Plain Old Java Object) class. It is a completely encapsulated class.

class POJO {
private int a=10;
public int getA() {
return a;
}
public void setA(int a) {
this.a = a;
}
}
public class Main {
public static void main(String args[]){
POJO p = new POJO();
System.out.println(p.getA());
}
}

5). Static class

A class can be made static only if it is a nested class.

Nested static class doesn’t need a reference of Outer class
A static class cannot access non-static members of the Outer class.

class JavaExample{
private static String str = "TutorialWorld";
static class NestedClassMethod{
public void display() {
System.out.println(str);
}
}
public static void main(String args[])
{
JavaExample.NestedClassMethod obj = new JavaExample.NestedClassMethod();
obj.display();
}
}

6). Inner Class


An inner class is a class that is declared within another class or method.

public class Main {
public static void main(String[] args) {
System.out.println("Outer Main Class");
}
class InnerClass {
public void inner() {
System.out.println("Inner class");
}
}
}