Java Fundamentals  «Prev  Next»


Lesson 1

Java Language fundamentals

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.

Module Objectives

This module will review your knowledge of Java language fundamentals, provide examples of their use, and help you to satisfy the following exam objectives:
  1. Identify correctly constructed package declarations and import statements.
  2. Identify how the main() method that is used to start execution of a class is formed.
  3. State the correspondence between index values in the argument array passed to a main() method and command line arguments.
  4. Identify all Java programming language keywords.
  5. State the effect of using a variable or array element of any kind when no explicit assignment has been made to it.
  6. 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).
Figure 2.1
Figure 2.1 Relationship between the class Person, the files Person.java and Person.class, and how one transforms into another

Java Refresher

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:
  1. Class A template that describes the kinds of state and behavior that objects of its type support.
  2. 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.
  3. 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.
  4. 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

SEMrush Software