SCJP by StanZ

Card Set Information

Author:
StanZ
ID:
298788
Filename:
SCJP by StanZ
Updated:
2015-03-20 17:19:42
Tags:
SCJP JAVA
Folders:
Programming
Description:
For SCJP candidates
Show Answers:

Home > Flashcards > Print Preview

The flashcards below were created by user StanZ on FreezingBlue Flashcards. What would you like to do?


  1. A Java program is mostly
    a collection of objects talking to other objects by invoking each other's methods.
  2. What is a Class?
    A template that describes the kinds of state and behavior that objects of it's type support.
  3. What is an Object?
    • At runtime, when the Java Virtual Machine (JVM) encounters the new keyword, it will use the appropriate class to make an object which is an instance of that class.
    • That object will have its own state, and access to all of the behaviors defined by it's class.
  4. What is State of an object? (aka instance variables)
    Each object (instance of a class) will have its own unique set of instance variables as defined in the class. Collectively, the values assigned to an object's instance variables make up the object's state.
  5. What is Behavior of an object? (aka methods)
    • When a programmer creates a class, he creates methods for that class.
    • Methods are where the class' logic is stored.
    • Methods arewhere the real work gets done. They are where algorithms get executed, and data gets manipulated.
  6. What are the three aspects of Java identifiers?
    • Legal Identifiers
    • The rules the compiler uses to determine whether a name is legal.

    • Sun's Java Code Conventions
    • Sun's recommendations for naming classes, variables, and methods.

    • JavaBeans Naming Standards
    • The naming requirements of the JavaBeans specification.
  7. Java organizes
    classes into <?>, and uses <?> to give programmers a consistent way to manage naming of, and access to, classes they need.
    Java organizes classes into packages, and uses import statements to give programmers a consistent way to manage naming of, and access to, classes they need.
  8. What are main rules regarding Legal Identifiers?
    Identifiers must start with a letter, a currency character ($), or a connecting character such as the underscore ( _ )

    Identifiers cannot start with a number!

    After the first character, 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 (for example: enum)

    Identifiers in Java are case-sensitive (foo and FOO are two different identifiers)
  9. is this a legal identifier? int _a;
    yes
  10. is this a legal identifier? int ______2_w;
    yes
  11. is this a legal identifier? int _$;
    yes
  12. is this a legal identifier? int -d;
    no
  13. is this a legal identifier? int $c;
    yes
  14. is this a legal identifier? int .f;
    no
  15. is this a legal identifier? int this_is_a_very_detailed_name_for_an_identifier;
    yes
  16. is this a legal identifier? int :b;
    no
  17. is this a legal identifier? int 7g;
    no
  18. is this a legal identifier? int e#;
    no
  19. List of keywords
    abstract boolean break byte case catch char class const continue default do double else extends final finally float for goto if implements import instanceof int interface long native new package private protected public return short static strictfp super switch synchronized this throw throws transient try void volatile while assert enum
  20. Classes naming standards are:
    The first letter should be capitalized, and if several words are linked together to form the name, the first letter of the inner words should be uppercase (a format that's sometimes called "camelCase"). For classes, the names should typically be nouns.

    • For example:
    • Dog
    • Account
    • PrintWriter
  21. Interfaces naming standards are
    the names should typically be adjectives like

    • Runnable
    • Serializable
  22. Methods naming standards are
    The first letter should be lowercase, and then normal camelCase rules should be used. In addition, the names should typically be verb-noun pairs.

    • For example:
    • getBalance
    • doCalculation
    • setCustomerName
  23. Variables naming standards are
    Like methods, the camelCase format should be used, starting with a lowercase letter. Sun recommends short, meaningful names, which sounds good to us.

    • Some examples:
    • buttonWidth
    • accountBalance
    • myString
  24. Constants naming standards are:
    Java constants are created by marking variables static and final. They should be named using uppercase letters with underscore characters as separators.

    • For example
    • MIN_HEIGHT

What would you like to do?

Home > Flashcards > Print Preview