The ability to create and compile Java source code files into running applications is the first skill acquired in becoming a Java programmer.
This involves creating packages for your classes and interfaces and importing classes and interfaces from other packages.
It also involves creating a properly formed main() method and using it to access command line arguments.
In addition, you learn how to create valid identifiers and work with primitive types.
These are the fundamentals of Java programming. The certification exam contains a number of questions that test your mastery of these fundamentals.This module reviews these topics and identifies important points that you should know in preparation for the exam.
This module will review your knowledge of Java language fundamentals, provide examples of their use, and help you to satisfy the following exam objectives:
Identify correctly constructed package declarations and import statements.
Identify how the main() method that is used to start execution of a class is formed.
State the correspondence between index values in the argument array passed to a main() method and command line arguments.
Identify all Java programming language keywords.
State the effect of using a variable or array element of any kind when no explicit assignment has been made to it.
State the range of all primitive data types, and declare literal values for String and all primitive types using all permitted format bases and representations.
Person Class Example
As you can see in figure 2.1, a person can be defined as a class Person. This class should reside in a Java source code file (Person.java). Using this Java source code file,
the Java compiler (javac.exe on Windows or javac on Mac OS X/Linux/UNIX) generates bytecode (compiled code for the Java Virtual Machine) and stores it in Person.class.
The scope of this exam objective is limited to Java classes (class Person) and Java source code files (Person.java).
A Java program is mostly a collection of objects talking to other objects by invoking each other's methods. Every object is of a certain type, and that type is defined by a class or an interface. Most Java programs use a collection of objects of many different types. Following is a list of a few useful terms for this object-oriented (OO) language:
Class A template that describes the kinds of state and behavior that objects of its type support.
Object At runtime, when the Java Virtual Machine (JVM) encounters the new keyword, it will use the appropriate class to make an object that is an instance of that class.
That object will have its own state and access to all of the behaviors defined by its class.
State (instance variables) Each object (instance of a class) will have its own unique set of instance variables as defined in the class. Collectively, the values assigned to an object's instance variables make up the object's state.
Behavior (methods) When a programmer creates a class, she creates methods for that class. Methods are where the class's logic is stored and where the real work gets done. They are where algorithms get executed and data gets manipulated