class : is a collection of abstract concepts, representing a product of generality, which defines attributes and behaviors (methods);
Object: An object is a representation of a personality that represents a single individual, each of which has its own independent property and relies on attributes to differentiate between objects.
Object = Instance
- Things known to the object itself: instance variables (instance variable)
- Actions that an object can perform: method
Class ≠ object
- Class is the model used to create an object
The inheritance mechanism enables subclasses to reduce duplicate code by inheriting the parent class code, which enables subclasses to choose to implement their own methods without having to alter the parent class.
Object class + Test object class
- Class name for testing = "Tested class name" +testdrive
- Test class with Main () function, object class without
- Using dots (.) To fetch the variables and methods of the object
Two uses of main ()
- Test the Real class
- Start the Java application
Points:
- Object-oriented design extension does not need to change the program code that has been tested before
- All Java programs are defined in the class
- Class describes how to create an object of type change as a blueprint
- Object autonomy, no need to care how he accomplishes the task
- Object has a known thing and can perform the completion
- A thing known to the object itself is called an instance variable, which represents the state of an object
- An action that an object can perform is called a method, which represents the behavior of an object
- When you create a class, you may also need to create a class for independent testing
- Classes can inherit from the more abstract parent class
- Java programs are a group of objects that talk to each other during the execution period.
Java Basic Learning (ii)--Object