A Java class is a group of Java methods and variables. Each Java source code file can contain one public class. The name of this public class must match the name of the Java source code file. If the public class is called “ballistics,” then the filename would be “ballistics.java.”

Example Java Class

class Ammunition {
int diameter;
int length;
String name;
}

Java Superclass

A Java superclass is a class which gives a method or methods to a Java subclass.

A Java class may be either a subclass, a superclass, both, or neither!

Java Subclass

A Java subclass is a class which inherits a method or methods from a Java superclass.

A Java class may be either a subclass, a superclass, both, or neither!

Java Final Class

A final class is a Java class which cannot be extended. This means that a final class can not become a superclass nor have a subclass.

Example Final Class

final class MySecureClass {
 // This class cannot be extended
}