Contents Index Object oriented and procedural languages Java error handling

ASA Programming Guide
  Introduction to Java in the Database
    A Java seminar

A Java glossary


The following items outline some of the details regarding Java classes. It is by no means an exhaustive source of knowledge about the Java language, but may aid in the use of Java classes in Adaptive Server Anywhere.

For more information about the Java language, see the online book Thinking in Java, by Bruce Eckel, included with Adaptive Server Anywhere in the file Samples\ASA\Java\Tjava.pdf.

Packages 

A package is a grouping of classes that share a common purpose or category. One member of a package has special privileges to access data and methods in other members of the package, hence the protected access modifier.

A package is the Java equivalent of a library. It is a collection of classes which can be made available using the import statement. The following Java statement imports the utility library from the Java API:

import java.util.*

Packages are typically held in JAR files, which have the extension .jar or .zip.

Public versus private 

An access modifier determines the visibility (essentially the public, private, or protected keyword used in front of any declaration) of a field, method or class to other Java objects.

Constructors 

A constructor is a special method of a Java class that is called when an instance of the class is created.

Classes can define their own constructors, including multiple, overriding constructors. Which arguments were used in the attempt to create the object determine which constructor is used. When the type, number, and order of arguments used to create an instance of the class match one of the class's constructors, that constructor is used when creating the object.

Garbage collection 

Garbage collection automatically removes any object with no references to it, with the exception of objects stored as values in a table.

There is no such thing as a destructor method in Java (as there is in C++). Java classes can define their own finalize method for clean up operations when an object is discarded during garbage collection.

Interfaces 

Java classes can inherit only from one class. Java uses interfaces instead of multiple-inheritance. A class can implement multiple interfaces. Each interface defines a set of methods and method profiles that must be implemented by the class for the class to be compiled.

An interface defines what methods and static fields the class must declare. The implementation of the methods and fields declared in an interface is located within the class that uses the interface: the interface defines what the class must declare; it is up to the class to determine how it is implemented.


Contents Index Object oriented and procedural languages Java error handling