Exforsys.com
 
Home Certification SCJP
 

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.



Read Next: SCJP 5: Chapter 1. Declarations, Initialization and Scoping (Part-4)



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape