Some small details in Java

Source: Internet
Author: User

1.abstract abstract class In addition to a more abstract method can have a constructor, when the subclass is instantiated, the first execution of the parent class constructor, you can call the Super keyword to specify the constructor method to call the parent class, in the execution of the subclass of the constructor method.

2. Abstract classes must have sub-classes, abstract methods have to be implemented in subclasses.

Only one abstract class can be inherited in 3.java, and multiple classes cannot be inherited.

4. Interfaces include global constants (final static adornments) and public abstract functions, and a subclass can inherit multiple interfaces.

5. an interface cannot inherit an abstract class, but it can inherit multiple interfaces, but an abstract class can inherit multiple interfaces.

6. Neither the interface nor the abstract class can be instantiated.

7. Using polymorphic, when the upward transformation, will call the subclass of the abstract method, if the subclass is not then called the parent class method, automatic implementation. The downward-grasping type needs to first establish the relationship between the subclass and the parent class, which takes place an upward transformation such as a a=new B ();

8.instanceof can be judged to be able to transform, to avoid classcastexception, and to solve the problem of different sub-categories belonging to their own characteristics.

9. A subclass does not integrate a common class, inheriting an abstract class or interface.

10. The interface can have internal class, inside the class can also have internal interface.

Some small details in Java

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.