1-Declarations and Access Control

  • Declare Classes & Interfaces
  • Develop Interfaces & Abstract Classes
  • Use Primitives, Arrays, Enums, & Legal Identifiers
  • Use Static Methods, JavaBeans Naming, & Var-Args

 

1-Declarations and Access Control_第1张图片

The objective says you have to know legal identifiers only for variable names, but the rules are the same for All Java components. So remember that a legal identifier for a variable is also a legal identifier for a method or a class. However, you need to distinguish between legal identifiers and naming conventions, such as the JavaBeans standards, that indicate how a Java Component should be named. In other words, you must be able to recognize that an identifier is legal even if it doesn't conform to naming standards. If the exam question is asking about naming conventions-not just whether an identifier will compile-JavaBeans will be mentioned explicitly.

Look for interface definitions that define constants, but without explicitly using the required modifiers. For example, the following are all identical:
java 代码
  1. public int x = 1;   
  2. int x = 1;   
  3. static int x = 1;   
  4. final int x = 1;   
  5. public static int x = 1;   
  6. public final int x = 1;   
  7. static final int x = 1;   
  8. public static final int x = 1;  

Any combination of the required (but implicit) modifiers is legal, as is using no modifiers at all! On the exam, you can expect to see questions you won't be able to answer correctly unless you know, for example, that an interface variable is final and can never be given a value by the implementing (or any other) class.
1-Declarations and Access Control_第2张图片
It is never legal to include the size of the array in your declaration. Yes, we know you can do that in some other languages, which is why you might see a question or two that include code similar to the following:
java 代码
  1. int[5] scores;  

The preceding code won't compile. Remember, the JVM doesn't allocate space until you actually instantiate the array object. That's when size matters.

你可能感兴趣的:(jvm,Access)