This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes keywords Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "keywords" Watch "keywords" New topic
Author

keywords

Higgledy Smith
Ranch Hand

Joined: Mar 07, 2006
Posts: 192
Does anyone memorize the Java keywords? Does anyone have any good mnemonics to share?
Vijay Gade
Ranch Hand

Joined: Jul 04, 2005
Posts: 81
One thing I can tell you for sure is, you might get confused if "goto" and "const" are keywords (if you have done c/c++ before). Just remember that they ARE keywords.
Thanks,
-Vijay
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2833
    
  11

Rote memorization of the keywords would be difficult and tedious. You should be a Java programmer if you're going for certification, so you should be familiar with most of the keywords because you use them. I suggest breaking them down into groups, e.g., private, protected, and public; const and goto; int, short, long, byte, float, double, boolean.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

I found it helpful to break key and reserved words into smaller groups that are logically related. As a memory technique, this is called "chunking." I'll just give you just a partial example of what I mean, because doing your own categorization -- in whatever ways make sense to you -- will also help you learn...

Primitives:
byte
short
int
etc...

Modifiers:
public
protected
private
static
etc...

Compilation Units:
package
import
class
interface
extends
etc...

Flow:
return
break
continue
do
while
etc...

Misc:
const
goto
etc...


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Greg Charles:
...I suggest breaking them down into groups...

Great minds think alike.
Higgledy Smith
Ranch Hand

Joined: Mar 07, 2006
Posts: 192
Some good ideas. I find on the mock exams I include words that ARE NOT keywords. It gets me confused.
Phil Kurian
Ranch Hand

Joined: Feb 26, 2006
Posts: 35
Hi,

Memorising keywords is good, but I've found questions in exams tend to fall into three streams when dealing with keywords.

The first type of question asks you to select from a list which are or are not keywords.

The second type is not as obvious. Sometimes they will give you a piece of code which seems to test on a particular feature of java (e.g. threads), but to be sneaky, they declare a method or a variable name the same as a keyword

e.g. private int switch;

In such as situation, you need to be able to recognise that the above statement is illegal because of the keyword use as a variable.

In saying that, sometimes the exam throws in a second level of sneakyness by declaring an int or method with a name which is from another language:

e.g. private int const;

This is a perfectly legal statement, but often it's quite easy to think that this is an error, particularly if you are scanning for incorrect field/method names.

The final type is when they ask you to fill in the blank keyword. This should be simple enough if you program with java on a regular basis.

What the people above said for memorisation worked for me. Just cluster them by the first letter and remember each block. then before the exam just string them all together.

(as far as I know they won't ask you to list all keywords or state how many java keywords there are - so rote memorization is overkill).


SCJP (1.4)
Vijay Gade
Ranch Hand

Joined: Jul 04, 2005
Posts: 81

In saying that, sometimes the exam throws in a second level of sneakyness by declaring an int or method with a name which is from another language:

e.g. private int const;

This is a perfectly legal statement, but often it's quite easy to think that this is an error, particularly if you are scanning for incorrect field/method names.


will definitely generate an error.

Thanks,
-Vijay
Phil Kurian
Ranch Hand

Joined: Feb 26, 2006
Posts: 35
Oops, even I forget my keywords/pseudo keywords


Been a while since I did the exam.

Change that statement to something like

private int struct;
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

The exam might present you with words that seem like keywords, but aren't. For example: main, then, run, start, yield, length, get, args, etc.

Note that key and reserved words are case sensitive. For example, "class" is a keyword, but "Class" is not.

Key and reserved words can be embedded in identifiers. For example, "superClass" and "ifTrue" are perfectly legal names.

Finally (no pun intended), some people miss "default" as a keyword, because they're thinking of access modifiers and know that there is no keyword for default access. But remember that "default" is a keyword used in switch-case blocks.
[ March 28, 2006: Message edited by: marc weber ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: keywords
 
Similar Threads
What does class loader means?
Continue & Break Keywords
greenhome ? ranch hand? What is the meaning ??
Java Class Keywords
Portal Description and Keywords