• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

keywords

 
Higgledy Smith
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone memorize the Java keywords? Does anyone have any good mnemonics to share?
 
Vijay Gade
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Greg Charles:
...I suggest breaking them down into groups...

Great minds think alike.
 
Higgledy Smith
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some good ideas. I find on the mock exams I include words that ARE NOT keywords. It gets me confused.
 
Phil Kurian
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Vijay Gade
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic