Method invocations for Java classes

Source: Internet
Author: User

I. Classification of classes:

1. General class

2. Abstract class (classes containing abstract methods)

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

Ii. Classification of methods:

1. Private methods (methods that are accessible only within the class)

2. Protection methods (methods that only the inner of the class and the subclasses of the class can access)

3, common methods (regardless of internal or external access to the method)

4, static method (can not instance the session object, through the class name. Method can be called)

5. Abstract methods (methods that are not implemented because of the signature of the method)

Iii. invocation of the method:

1. General class: Instantiate an object of that class and then access it through the image. For example:

Class A {

Public void Method1 () {

System.out.println ("I am Method 1 of Class A");

}

}

public static void Main (string[] args) {

A a=new a ();

A.method1 ();

}

2, Static class: can be directly accessed through the class name, without instantiating the object. For example:

Class static A {

public static void Method1 () {

System.out.println ("I am Method 1 of Class A");

}

}

public static void Main (string[] args) {

A.method1 ();

}

3. Abstract class:

An abstract class cannot instantiate an object by itself.

An abstract class can only be instantiated by a subclass that inherits from him.

This is the subclass instantiation of the parent class object.

Method invocations for Java classes

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.