Java Programming Language Class, Interface (Class vs Interface)
Java Programming Language: Classes vs. Interfaces What is a class?Classes in Java are almost the same as C++ classes, in that they define an abstract datatype, with its particular fields and methods. Each object is an instance of a class, and follows the class prototype that defines the variables and methods common to all objects of a certain kind. Each instance of a class must be instantiated, after it is declared, unlike in C++. This is usually done with the keyword "new" . Classes may have inheritance from other classes, as they do in C++, meaning they incherit all the properties of the parent class. This is usually done with the keyword "extends" . So for example, a simple sub-class declaration with inheritance from another class might look like this: class Window extends Frame {} The new class is window which contains all the properties of a Frame. Mind you, sub-classes are not limited to the properties they inherit, they may add variable...
Comments
Post a Comment