Java class method calls and variables

Source: Internet
Author: User

I. Tired classification:

1. Common class

2. abstract class (class containing abstract methods)

3. Static class (class that can be used without instantiation)

Ii. Classification of methods:

1. Private method (only methods within the class can be accessed)

2. protection methods (only internal classes and sub-classes of this class can access the methods)

3. Public methods (accessible either internally or externally)

4. Static Method (you can use a class name without instantiating an object. Methods that can be called)

5. Abstract METHODS (only method signatures are not implemented)

3. Call methods:

1. Common class: instantiate an object of this class and access it through the object. For example:

Classs {Public VoidMethod 1() {System. Out. println ("Method 1 of Class");}}Public Static VoidMain (string [] ARGs) {=NewA (); A. Method1 ();}

2. Static class: the class name can be used for direct access without instantiating objects. For example:

Class StaticA {Public Static VoidMethod1 () {system. Out. pringtln ("Method 1 of Class")}}Public Static VoidMain (string [] ARGs) {A. Method1();}

3. abstract class: the abstract class itself cannot instantiate an object. The abstract class can only be used as an instance by its subclass.

That is, the Child class instantiates the parent class 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.