Java Basic Learning (ii)--Object

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.