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

 

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.
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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值