Scjp

Solo disponible en BuenasTareas
  • Páginas : 80 (19753 palabras )
  • Descarga(s) : 0
  • Publicado : 3 de septiembre de 2012
Leer documento completo
Vista previa del texto
* Chapter 1: Declarations and Access Control:
*
* Certification Objetives:
* - Declare Classes & Interfaces
* - Develop Interfaces & Abstract Classes
* - Use Primitives, Arrays, Enums & Legal Identifiers
* - Use Static Methods, Java Beans, Naming & Var-Args
*
* Identifiers & JavaBeans
* 1.3: Develop code that declares, initializes and uses primitive arrays, enums, and objects asstatic, instance, and local variables.
* Use legal identifiers for variable names.
*
* 1.4 Develop code that declares both static and non-static methods and uses a variable-length argument list.
*
*/
Three aspects of Java identifiers that we cover here are:
← Legal Identifiers
← Sun’s Java Code Conventions
Sun's recommendations for naming classes, variables andmethods
← JavaBeans Naming Standards
You don’t need to study the JavaBeans spec for the exam, you do need to know a few basic JavaBeans naming rules.

LEGAL IDENTIFIERS
Rules you DO need to know:
• Identifiers must start with a letter, a currency character ($), or a connecting carácter such as the underscore ( _ ). Identifiers cannot start with a number!
• After the firstcharacter, identifiers can contain any combination of letters, currency characters, connecting characters, or numbers.
• In practice, there is no limit to the number of characters an identifier can contain.
• You can't use a Java keyword as an identifier. Table 1-1 lists all of the Java keywords including one new one for 5.0, enum.
• Identifiers in Java are case-sensitive; foo and FOOare two different identifiers.

Sun’s recommendations:
- Classes and interfaces: First letter should be capitalized. If several words are linked together to form the name, the 1st letter of the inner words should be uppercase (format “camelCase”
Interfaces: adjectives
- Methods: 1st letter should be lowercase (format camelCase). Name. verb-noun
i.e getBalance, doCalculation, setCustomerName- Variables: format camelCase. Starting with lowercase letter. Short, meaningful names.
i.e. myString, buttonWidth.
- Constants: marking variables STATIC and FINAL. Named using uppercase letters with underscore characters as separators. Ie. MIN_HEIGHT.

JavaBeans Standards
JavaBeans are Java classes that have properties. Set and Get methods.
get, set, is
Setter marked public, with a voidreturn type.
If the property is a Boolean.: getStopped(), or isStopped()

JavaBean supports events, which allow components to notify each other when sth happens. Los objetos que reciben información de q un evento ha ocurrido se llama “listeners”
Rules you DO need to know:
- add i.e addActionListener
- remove
- The type of listener to be added or removed must be passed asargument.


Declare Classes (Exam Objective)

1.1  Develop code that declares classes (including abstract and all forms of nested classes), interfaces, and enums, and includes the appropriate use of package and import statements (including static imports).

Ways in which you can declare and modify (or not) a class

Source File Declarations Rules
- Solo una clase pública por archive decódigo.
- Comentarios pueden aparecer al inicio o fin de cualquier línea en el código fuente.
- Si hay una clase pública en el archivo, el nombre del archivo debe coincidir con el nombre de la clase pública.
- Si la clase es parte de un paquete, the package statement debe ser la primera línea en el código, antes ningún import debe estar presente.
- Si hay IMPORT statements, deben irentre PACKAGE statement and CLASS declaration. Si no hay package statement, IMPORT debe ser la primera línea.
- Un archivo puede tener mas de una clase no pública.
- Archivos con clases no públicas pueden tener un nombre que no coincida con ninguna clase en el archivo.

Class Declarations and Modifiers
Modifiers:
- Access modifiers: public, protected, private
- Non-access...
tracking img