Every day, a bit of Java face question (a)

Source: Internet
Author: User

(1) Use of the static field in Java:

What is static?

It is a Java modifier that defines static variables and static methods.

When do you use it?

Typically used in tool classes, the static method is modified and then used by other classes of methods.

The use method is directly through the class name. method is used, eliminating the hassle of new objects and then calling methods.

What to pay attention to?

It is important to note that variables and methods are defined as static and will be loaded first when the class is loaded.

The fields and methods referenced by the static method can only be static.

(2) Differences and linkages between interfaces and abstract classes

Important Concept!

Interface Definition action (what to do), abstract class definition root (what is it)


What is an interface?

The interface is actually not a class, because it cannot be instantiated.

An interface is an abstraction of a method, which is abstract by default.

The interface must be implemented before it can be used.

What is an abstract class?

Object-oriented domain everything is an object, but the new object requires that the properties of the object be OK so that the new object can be instantiated and used.

But sometimes some concepts are not specific, such as person, do not know what his specific appearance, so sometimes need to pull out of such classes.

Differences and linkages

A class can inherit multiple interfaces, but abstract classes do not, only one is implemented.

Care about the access rights of properties and methods with abstraction, care for Java's multi-inheritance interface.

Every day, a bit of Java face question (a)

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.