Sun certification Study Notes series-statements and Access Control

Source: Internet
Author: User

Identifier

The identifier can start with a letter, underscore, or currency symbol.

After the first character, the identifier can also contain numbers

The identifier can be of any length

You must use the camelcase rule to name the javebeans method. The method must start with set, get, is, add, and remove.

 

Declaration Rules

A source code file can only have one public class

If the source file contains a public class, the file name should be the same as the public class name.

A file can have only one package statement, but multiple import statements

The package Statement (if any) must be in the first line of the source file

The Import Statement (if any) must be placed after the package statement and before the class declaration

If no package statement exists, the import statement must be the first statement in the source file.

The package and Import Statement are applied to all classes of the file.

Classes without public files have no naming restrictions

 

Class access modifier

There are three access modifiers: Public protected private

There are four access levels: public, protected, default, and private

Class can only have one public or default access

Classes with default access are only visible to classes in the same package

Classes with public access are visible to all classes in all packages.

 

Class Modifier

Class can also be modified to final, abstract, strictfp

Classes cannot be both final and abstract.

The final class cannot be any more molecular class

Abstract classes cannot be instantiated.

An abstract method in a class means that the entire class must be abstract.

Abstract classes can have abstract and non-abstract methods.

The first concrete class of the extended abstract class must implement all its abstract methods.

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.