Can the abstract method be static at the same time, can it be both native and synchronized?

Source: Internet
Author: User

Abstract methods can not be static, because the abstraction of the method is to be implemented by the quilt, and static and the sub-class is not related!

The native method means that the method is implemented with another platform-dependent programming language, and there is no problem with the implementation of the quilt class, so it cannot be abstract and cannot be mixed with abstract. For example, the Fileoutputsteam class wants to deal with hardware, and the underlying implementation uses an operating system-related API implementation, for example, in the C language of Windows, so view the source code of the JDK, You can see that the FileOutputStream open method is defined as follows:

Private native Void Open (Stringname) throws FileNotFoundException;

If we want to use Java to call the C language function written by others, we can not directly call, we need to follow the Java requirements to write a C language function, and our C-language function to call someone else's C language function. Because our C language function is written according to Java requirements, we this C language function can interface with Java, Java side docking way is to define the method corresponding to our C function, the corresponding method in Java does not need to write the specific code, but need to declare native before.

I don't think it's a problem with synchronized and abstract, because I've never seen it in my years of study and development, and I think synchronized should be useful in a specific way. Furthermore, the synchronization lock object used by the synchronized synchronization on the method is this, and the abstract method cannot determine what this is.

Can the abstract method be static at the same time, can it be both native and synchronized?

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.