Java abstract classes and interfaces

Source: Internet
Author: User
  • Abstract classes: Variables and abstract methods
  1. First of all, we want to think of the keyword: abstract (the keyword used to define abstract classes and methods)
  2. Then there are n more abstract methods and n>=0; means that there can be no abstract method in the abstract class.
  3. There can be ordinary member methods in an abstract class (different interfaces: only abstract methods)
  4. Abstract classes are not created to create objects.
  • The difference between using an abstract class to implement an interface and using an ordinary class to implement an interface:
  1. Abstract classes allow the existence of abstract methods, so it is not necessary to implement all the abstract methods in the interface
  2. But the existence of abstract methods is not allowed in ordinary classes, so it is necessary to implement all the abstract methods in the interface
  • Abstract method:
  1. Description: Implementing a unified specification
  2. Role: Subclasses of the class must implement all the abstract methods in the class

Java abstract classes and interfaces

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.