Abstract methods for Java abstract classes

Source: Internet
Author: User
1. Why do I need abstract classes? How do I define an abstract class?
* is a template mode. Abstract classes provide a generic template for all subclasses, which can be extended on the basis of this template.
* By abstract class, you can avoid the arbitrariness of sub-class design. Through abstract classes, we can strictly restrict the design of subclasses, so that subclasses are more common.
2. Key points:
Classes that have abstract methods can only be defined as abstract classes.
Abstract classes cannot be instantiated, and abstract classes cannot be instantiated with new.
An abstract class can contain properties, methods, and construction methods. However, the construction method cannot be used for new instances, only for the quilt class invocation.
Abstract classes can only be used for inheritance.
Abstract methods must be implemented by the quilt class, and the abstract parent class can also be inherited with an abstract subclass.
3. Abstract class is the class that contains the abstract method (abstract class)
4. The abstract method is that only the declaration of the method has no method body.
5. There can also be non-abstract methods in abstract classes.
6. An abstract class cannot construct an object but can be a type.

Abstract methods for Java abstract 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.