Java abstract class attention issues

Source: Internet
Author: User

When you know that a subclass of a class will implement a method differently, it is useful to declare the class as an abstract class, and you can share the same parent class method without having to define it.
The relationship between abstract classes and abstract methods: classes containing abstract methods must be abstract, and abstract classes do not necessarily contain abstract methods. The meaning of the existence of abstract classes is to be inherited. A class inherits an abstract class and must implement all the abstract methods within the abstract class , otherwise, this class is also an abstract class.
The abstract modifier is used to decorate the class and member Method 1: Abstract classes are represented by an abstraction class, and abstract classes cannot be instantiated. 2: Abstract methods are represented by the abstraction method, and there is no method body for abstract methods. Abstract methods are used to describe what functions the system has, but do not provide specific implementations. Abstract rule: 1: An abstraction class can have no abstract method, but a class with an abstract method must be defined as an abstract class, and if a subclass inherits an abstract class and the subclass does not implement all the abstract methods of the parent class, then the subclass is also defined as an abstract class, otherwise the compilation will go wrong. 2: Abstract class does not have a constructor method , nor is it an abstract static method. But there can be non-abstract construction Method 3: abstract class cannot be instantiated, but can create a reference variable, the type is an abstract class, and let it refer to an instance of a subclass of a non-abstract class 4: Can not be decorated with the final modifier, (with the final how to inherit, hehe)
5: Another silly but important question: Abstract classes cannot be instantiated.
6:
Abstract cannot be with final,private,static


Java abstract class attention issues

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.