This chapter helps you to prepare for the exam by covering the following objectives from the "Language Fundamentals" section of the Sun testing objectives:
Identify correctly constructed source files, package declarations, import statements, class declarations (of all forms including inner classes), interface declarations and implementations (for java.lang.Runnable or other interfaces described in the test), method declarations (including the main method that is used to start execution of a class), variable declarations, and identifiers.
- To be a Java programmer, you must know how to create packages, import classes and interfaces from other packages, and create a program's main() method. The certification exam will definitely test your knowledge of these topics.
State the correspondence between index values in the argument array passed to a main() method and command-line arguments.
- The indexing of command-line arguments differs from C and C++ to Java. Exam questions in this area are designed to trip up C and C++ programmers.
Identify all Java programming language keywords and correctly constructed identifiers.
- You must know which keywords Java reserves so that you don't use them as identifiers in your programs. You can count on seeing an exam question that will test your knowledge of Java's keywords. Creating a simple identifier is basic to Java programming. You are likely to see an exam question that tests your ability to distinguish valid identifiers from invalid identifiers.
State the effect of using a variable or array element of any kind, when no explicit assignment has been made to it.
- Java automatically initializes field variables and arrays. This is important to know when you are developing Java programs. You will see questions on initialization on the certification exam.
State the range of all primitive data types, and declare literal values for String and all primitive types using all permitted formats, bases, and representations.
- You must know the range of a type to determine when a value is out of range.
You also must know how to create primitive values for each type. This is another
rich area for exam questions.
The Structure of Java Programs
Importing Classes and Interfaces from Other Packages
The main() Method
Identifiers and Keywords
Primitive Types and Literal Values
As you read through this chapter, concentrate on the following key items:
How to identify a Java package.
How to import classes and interfaces from other packages.
How to create a program's main() method.
Try creating a Java program of your own and running it. Put it in a named package and import classes and interfaces of other packages. Identify those things that you need to do to make it work.
How to access command-line arguments.
Modify your program to work with command-line arguments.
How to create valid identifiers.
Memorize the rules for valid identifiers.
How field variables and arrays are initialized.
Create a program with different types of field variables and arrays but don't explicitly initialize them. Display their values to see how Java initializes them.
What the range of each primitive type is.
You should memorize these ranges because you will need to know them for the exam.
How to create literal values of each primitive type.
How to create String literal values.
Write a program that provides an example of each type of literal value.