`
javalion
  • 浏览: 13574 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

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.

相关推荐

    OCA OCP Java SE 7 Programmer I - II Study Guide(SYBEX,2014)

    * Declarations and access control * Object orientation * Assignments * Operators * Strings and arrays * Flow control and exceptions * Assertions and Java 7 exceptions * String processing, data ...

    SCJP6 Sun Certificated Programmer for Java 6 Study Guide (Exam 310-065) 英文原版

    In the first chapter, the focus is on understanding declarations and access control within Java. Key concepts include: - **Variable Declarations**: This section covers the basics of declaring ...

    The C programming Language(chm格式完整版)

    Chapter 1: A Tutorial Introduction Getting Started Variables and Arithmetic Expressions The for statement Symbolic Constants Character Input and Output File Copying Character Counting Line ...

    OCP Java SE 8 Programmer II Exam Guide (Exam 1Z0-809)

    Declarations, access control, and enums Object orientation Assertions and exceptions Dates, times, locales, and resource bundles I/O and NIO Generics and collections Inner classes Lambda expressions ...

    Google C++ Style Guide_英文版.pdf

    - **Access Control:** Use private, protected, and public access specifiers appropriately. Consider using friend functions/classes sparingly. - **Declaration Order:** Place variable and function ...

    OCA Java SE 8 Programmer I Exam Guide (Exams 1Z0-808) 高清完整azw3版

    • Access control • Object orientation • Assignments • Operators • Flow control • Exceptions • Strings • Arrays • ArrayLists CD ICON Electronic content includes: • 200+ practice ...

    The Art of Assembly Language Programming

    Pointers to Structures 5.7 - Sample Programs 5.7.1 - Simple Variable Declarations 5.7.2 - Using Pointer Variables 5.7.3 - Single Dimension Array Access 5.7.4 - Multidimensional Array ...

    acpi控制笔记本风扇转速

    output trace mechanism and has a much larger code and data size. Previous Release: Non-Debug Version: 78.1K Code, 17.1K Data, 95.2K Total Debug Version: 155.4K Code, 63.1K Data, 218.5K Total ...

    The C programming Language

    Control Flow Statements and Blocks If-Else Else-If Switch Loops - While and For Loops - Do-While Break and Continue Goto and labels <br>Chapter 4: Functions and ...

    Turbo C++ 3.0[DISK]

    instant access to the Borland forums with their libraries of technical information and answers to common questions. If you are not a member of CompuServe, see the enclosed special offer, and ...

    C# 5.0 Programmer’s Reference

    Beginning through intermediate-level programmers will benefit from the accessible style of C# 5.0 Programmer’s Reference and will have access to its comprehensive range of more advanced topics....

    Turbo C++ 3.00[DISK]

    instant access to the Borland forums with their libraries of technical information and answers to common questions. If you are not a member of CompuServe, see the enclosed special offer, and ...

    DevExpress VCL 13.2.5 D7-DXE6 FullSource

    •Q581933 - At design time, modifying any property of a control selected on the parent form selects a control on an inherited form if the parent form contains TdxWizardControl and/or ...

    Selected.Topics.in.Cplusplus.15117

    Forward Declarations, Compiling and Linking Copy Constructor and Object Cloning Class Member Access Class member offsets Function Pointers Function Shadowing Understanding the Destructor Operator ...

    Program in LUA 2nd Edition.rar

    14.2 Global-Variable Declarations 131 14.3 Non-Global Environments 132 15 Modules and Packages 137 15.1 The require Function 138 15.2 The Basic Approach for Writing Modules 141 15.3 Using ...

    scjp考试大纲-官方英文版

    #### 一、声明与访问控制 (Declarations and Access Control) 在SCJP认证考试中,考生需要掌握以下知识点: - **数组的声明与初始化**:能够编写代码来声明、构造并初始化任何基本类型的数组,包括使用所有允许的...

    Addison.Wesley.C++.by.Dissection.2002.pdf

    - **Statements:** Covers different types of statements, including assignment, conditional, loops, and control flow. - **Software Engineering: Debugging:** Emphasizes debugging techniques and tools. - ...

    EurekaLog_7.5.0.0_Enterprise

    8)....Fixed: Removed some unnecessary file system access on startup 9)....Fixed: Possible wrong font size in EurekaLog tools 10)..Fixed: Ignore timeouts from Shell_NotifyIcon 11)..Fixed: Possible ...

Global site tag (gtag.js) - Google Analytics