Section 4: Language Fundamentals ( Chapter 2 )

  • Identify correctly constructed package declarations, import statements, class declarations (of all forms including inner classes) interface declarations, method declarations (including the main method that is used to start execution of a class), variable declarations, and identifiers.

  • Identify classes that correctly implement an interface where that interface is either java.lang.Runnable or a fully specified interface in the question.

  • 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. Note: There will not be any questions regarding esoteric distinctions between keywords and manifest constants.

  • 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 formats and data types and declare literal values for String and all primitive types using all permitted formats bases and representations.

Study Notes

The structure of a Java source file containing declarations of package and import statements, interfaces, and classes follows certain rules. Classes, interfaces, methods, and variables can be defined within several contexts, and the contexts influence the meaning of the declaration and the modifiers applicable. The modifiers used also influence the restrictions that apply for the implementation of methods. Certain rules of consistency must be observed when extending classes, and when extending or implementing interfaces. Variables can be shadowed by extending classes, methods can be overridden by extending classes. Methods are distinguished from each other at compile time, based on the method signature.

A method with the signature public static void main(String[] args) serves as the entry point for executing applications. The parameter in the main() method corresponds to the program arguments given on the command line.

It is important to know all the keywords in the Java language and to be able to identify valid identifiers.

Each primitive data type has a range of valid values and a default value. Depending on the context of the declaration, some variables are either initialized to a default value or remain uninitialized until first assigned a value. Code that tries to access uninitialized variables is illegal. Elements of array objects are always initialized. Various notations are used to specify literals.