Chapter 7: Creating a Web Form
There are certain Java concepts that will be used throughout this guide, including object (constructor, instantiation), class, data attributes, methods, encapsulation, information hiding, Polymorphism, and inheritance.
An object is an instance of a class. There should be a constructor to create the object.
Data and Attributes
The data and attributes associated with an object are know as the object's properties.
Methods (functions) are the actions an object can perform.
Encapsulation means binding an object's state (properties) and behavior (methods) together. When you create a class, you are encapsulation that object's data and methods.
Information hiding means that the object's data and attributes are protected from change by other parts of the application.
Polymorphism allows actions (methods) to act differently based on the object performing the action or the object the action is being performed on. For example, The sound that a cat makes is "meow". So, if an object had a method,
makeSound() we could use that method on a "cat" object and it would return "meow". If we were to use this methiod on a "dog" object, it would return "bark". Let's pretend that all animals can
makeSound(). So depending on the type of animal (object) the method does something different.
Inheritance allows for extending objects and code reuse. For example, if we had an object, "person" with properties (first name, last name, etc.) and methods (walk, talk, eat, etc.), we could "extend" the "person" object to a subclass such as a "student". The "student" object would "inherit" the parent object's properties and methods. The "student" object could then have it's own properties (classes, grades, etc.) and methods (enroll, graduate, etc.).