• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Keywords in the SCJP exam

 
ADSWED
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I have a question regarding the latest Programmer Certification.

In the book "Complete Java 2 Certification" (The Study Guide 4th ed by Heller and Roberts) the word "assert" is listed as a keyword or reserved word (see p. 5) but "assert" is not contained on tha page:
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html

What is true for the latest version? Is "assert" protected or not?

Best regards,
Anders
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The book you refer is for J2SE 1.3, while assert is added in J2SE 1.4.

Nick
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there are any more keyword added in J2SE 1.5 .

thank you very much .
 
Joseph Maddison
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a little more tricky than simply, it was added in 1.4. For example, the following compiles under Java 1.4 without error:



So, it is a keyword, but it can be used as if it weren't, for backward compatibility. Now, if you want to use assertions, you have to compile with the flag "-source 1.4" and run the JVM with -ea (enableassertions). Otherwise, the following would not compile:


Hope this helps,
jdmaddison
 
ADSWED
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again!

I think JD got it right! Thank you v. m. everyone.

// Anders
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic