Java object-oriented abstract class

Source: Internet
Author: User

    1. Abstract class:

      Classes that are decorated with the abstract keyword are called abstract classes. An abstract class cannot be instantiated, that is, it cannot be new to an abstract class object

    2. Abstract method: Methods that are modified by using the abstract keyword are called abstract methods

      1. Abstract method, there is a declaration, no implementation, the method behind the semicolon can not be saved;

      2. Abstract methods need to be defined in abstract classes, compared to abstract methods, the previously defined methods are called concrete methods (declarations, implementations);

    3. If a class contains an abstract method, then the class must be an abstract class.

    4. If a class is an abstract class, then the class can contain concrete methods (declarations, implementations);

    5. If a class contains an abstract method, the class must be declared as abstract class, that is, the class must be an abstraction, and conversely, if a class is an abstract class, then the class can contain either abstract or concrete methods

    6. In either case, as long as a class is an abstract class, the class cannot be instantiated

    7. In cases where a subclass inherits the parent class (the parent class is an abstract class), the subclass must implement all the abstract methods defined in the parent class, otherwise the subclass declares an abstract class

Package Com.yuanzijian02;public class Test {public static void main (string[] args) {}}abstract class T {public abstract Vo Id method ();p ublic void Test () {System.out.println ("Test");}}      Class R extends t{public void method () {System.out.println ("test"); }}

8.

Java object-oriented abstract class

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.