alt
Sponsored links
Certification Series
Online Training
Career Series
Exforsys
Exforsys arrow Certification Series arrow SCJP arrow SCJP 5 : Chapter 1. Declarations, Initialization and Scoping (Part-3)
Site Search


SCJP 5 : Chapter 1. Declarations, Initialization and Scoping (Part-3)

Chapter 1. Declarations, Initialization and Scoping
(Part-3)

Develop code that declares, initializes, and uses primitives, arrays, enums, and objects as static, instance, and local variables. Also, use legal identifiers for variable names.

 

Develop code that declares, initializes, and uses primitives, arrays, enums, and objects as static, instance, and local variables. Also, use legal identifiers for variable names.

Variable Identifiers

Variable names must be legal Java identifiers:

  • Keywords and reserved words may not be used.
    .
  • It must start with a letter, dollar sign ($), or underscore (_).
    .
  • Subsequent characters may be letters, dollar signs, underscores, or digits.
    .
  • It is case sensitive. For example, mymodel and MyModel are different identifiers.

The following are not legal variable names:

.
My Variable // Contains a space
.
9pins // Begins with a digit
.
a+c // The plus sign is not an alphanumeric character
.
testing1-2-3 // The hyphen is not an alphanumeric character
.
O'Reilly // Apostrophe is not an alphanumeric character
.
OReilly_&_Associates // ampersand is not an alphanumeric character

Keywords: abstract assert boolean break byte case catch char class const continue default do double else enum extends false final finally float for goto if implements import instanceof int interface long native new null package private protected public return short static strictfp super switch synchronized this throw throws transient true try void volatile while
.
The goto keyword is not used.
.
The const is also not used.
.
The assert is a new keyword added with Java 1.4
.
The enum is a new keyword added with Java 5.0

______________

Author: Mikalai Zaikin. Please Click Here to visit Authors site for any updates and changes to the study notes.


Trackback(0)
Comments (0)add comment

Write comment

busy
 
< Prev   Next >
Exforsys Offers
© 2008 Exforsys.com
Joomla! is Free Software released under the GNU/GPL License.
Page copy protected against web site content infringement by Copyscape