Java Quick Review

Java is a fully object-oriented language.

classes, objects, instances
Every Java program must have at least one class
Java classes have functions (methods) and properties (attributes)
Creating an object from a class is called instantiation. An infinite number of objects can be created from a class.
An object is a class instance that defines data it can store and the operations possible on this data.
A base type instance variable stores a primitive value.
A reference type instance variable stores a reference to an object.
Instantiation code:

Car c = new Car();

Note that c is a reference variable.
Java is a statically typed language. Programmer needs to declare each variable with a name and a type. Declaration a variable:

String instrument = "violin";

The value of a constant never changes. The keyword "final" is used to declare a constant. Declaring a constant:

final double pi = 3.14159265;

Note that pi is a base type variable since it's type is primitive.

Variables
Java has 8 primitive types: byte, short, int, long, float, double, char, boolean. Every primitive has a corresponding wrapper class: Byte, Short, Integer, Long, Float, Double, Character, Boolean. Boxing and autoboxing convert primitives to wrapper objects. Unboxing refers to converting wrapper object to primitive.

A variable in a method has local scope i.e. not visible outside the method. A variable declared inside a block such as a for loop has block scope. A class variable is visible to all methods in the class. static variables are shared by all objects of a class.

final variable is a constant
final method cannot be overridden
final classes cannot be subclassed. methods of such classes are implicitly final.

Java classes are organized into packages
Fully Qualified Name (FQN) of a class is package.class or

import package
use class_name

Inheritance = derive one class from another

Casting is an operation that permits variable type change

Review in Question Form

Difference between Java and other high level programming languages such as C++
- fully object-oriented; you cannot access data without using a class method
- portable; a class compiled in windows can be used on Linux without recompilation
- automatic garbage collection
Difference between class, object, instance
Class is the blueprint to code objects. An instance is the realization of an object. Objects are copies of a class with specific attributes.
Difference between base type variables and reference type instance variables
Base type variables are variables with a primitive type such as int, float, double, etc. Reference type variables are of other classes.