An Ontology of Java

The course gives a tender introduction to Java.

Control

Java supports the following control structures.

Classes

A class which works exclusively with int in Java can be defined in the following way.

public class A {
		// Instance Variable
		public int instance_var;
		
		// Static Variable
		public static int static_var;
		
		// Constructor
		public A (int param) {
				instance_var = param;
		}
		
		// Instance Method
		public int instance_method (int x) {
				// ...
		}
		
		// Static Method
		public static int static_method (int x) {
				// ...
		}
}

When a variable of a class type is declared, it can then be assigned to the memory address of an instance of that class.

    A a_Object       =          new A(arg);
// declaration   assignment    instantiation

Modifiers

Classes in Java use certain keywords to control what its members can do. These keywords are known as modifiers and this course covers 2 types: access and static.

Access modifiers tell the compiler who can access a certain member. public members can be accessed by anyone, whereas private members can only be accessed within the class.

Static modifiers help the compiler tell if a member belongs to a specific instance of a class or to the class itself. static members are invoked through class name and static methods cannot access instance variables. Instance members sharing the same name as static members are prioritized when accessed through an instance.

Program Lifecycle

A Java program Program.java is compiled into a byte code file Program.class which is then interpreted through the Java Virtual Machine, an intermediary environment between Java code and low level hardware.