What does a Java class consist of?
A Java class consists of fields and methods.
Fields are variables in a class used to store data. They can be either primitive data types (such as int, double, etc.) or reference types (such as strings, arrays, etc.). Fields can be instance fields (each object has its own copy) or static fields (shared by all objects).
Methods are code blocks within a class that perform certain operations. They can access and manipulate fields, and can either return a value or return nothing. Methods can be instance methods (which can only be called through objects) or static methods (which can be called directly through the class).
In addition to fields and methods, Java classes can also contain constructors, static blocks, inner classes, and so on. Constructors are used to create objects and initialize field values. Static blocks are used to perform some initialization operations when the class is loaded. Inner classes are classes defined within other classes that can access the fields and methods of the outer class.