Java Class
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
}
- Override
Sometimes a subclass inherits a method from a superclass that doesn’t quite fit its needs. Perhaps the subclass inherited twenty methods and just one of them wasn’t quite right. In that case, the subclass would override that method by redefining that method itself. This override does not affect the method as defined in the superclass....
- Java Method
A Java method is a set of Java statements that can be included inside a Java class. Java methods are similar to functions or procedures in other programming languages. There are many different types of Java methods: Final Method Public Method Private Method Package Method Instance Method Protected Method Static Method Main Method The Main [...]...
- How to Declare a Constant in Java
Java does not directly support constants. However, a static final variable is effectively a constant. The static modifier causes the variable to be available without loading an instance of the class where it is defined. The final modifier causes the variable to be unchangeable. Naming Standards for Java Constants Java constants are normally declared in [...]...
- Inheritance
Inheritance is what happens when a subclass receives variables or methods from a superclass. It is also when one class passes down its properties to another class. The main reason for inheritance is reusability. Distinguishing a new class from an existing class is called derivation. The old class is referred to as the base class [...]...
- Java vs. C++
C++ supports pointers; Java does not (Java does have object references) C++ supports mutiple inheritance directly; Java supports multiple inheritance only through interfaces C++ supports operator overloading; Java does not C++ supports global variables; Java does not (sort of) C++ supports #define; Java does not C++ supports typedef; Java does not C++ supports enum; Java [...]...





