Java Learning Notes (i)

Source: Internet
Author: User

1, The difference between abstract class and interface:

(1), interface data members must be initialized, and the data members are constants;

(2), the method in the interface must all be declared as abstract, that is, theinterface can not be as tired as the definition of a general method, must be all "abstract method."

2 . Only single inheritance and multi-layer inheritance are supported in Java, and (one-time) multiple inheritance is not supported; On the other hand, interfaces just support (once) multiple inheritance.

3.in Java ,the object class is the parent class of all classes, and if a class does not inherit other classes, the default object class is its parent class.

4. External class and inner class:

(1) The external class cannot access the attributes declared in the inner class, but the inner class can access the attributes declared by the outer class;

(2) If you can declare an inner class with static, the inner class becomes an outer class, but the class cannot access properties of the non-static type in the outer class ;

(3) An inner class can be called from outside a class by creating an object, as long as the inner class is declared as public ;

(4) An inner class can also be defined in a method in a class that accesses a variable declared in a class and a local variable of the final type declared in the method , but does not have access to the final Variable of type (reason: declaration period);

(5) An inner class can inherit an abstract class or implement an interface;

(6) anonymous inner class: The class that implements the interface is not explicitly declared, but the method in the interface is implemented in the program, and the whole red thread class is passed to the method of the outer class.

5. Inherit an abstract class and implement multiple interfaces.

6, anonymous object: That is, there is no explicit declaration of the object, only use the object once, there is no specific object name reference it, and then be recycled by Java garbage collector.


This article is from the "book Notes" blog, please be sure to keep this source http://xiexiao.blog.51cto.com/10173801/1652138

Java Learning Notes (i)

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.