About me
Services
Projects
Design Patterns
Archive
Contact
home > Archive > programmer exam prep > what is?

What is?

Abstract keyword

Here is what Webster has to say;

Main Entry: 1ab·stract
Pronunciation: ab-'strakt, 'ab-"
Function: adjective
Etymology: Medieval Latin abstractus, from Latin, past participle of abstrahere to drag away, from abs-, ab- + trahere to pull, draw
Date: 14th century
1 a : disassociated from any specific instance <abstract entity> b : difficult to understand : ABSTRUSE <abstract problems> c : insufficiently factual : FORMAL <possessed only an abstract right>
2 : expressing a quality apart from an object <the word poem is concrete, poetry is abstract>
3 a : dealing with a subject in its abstract aspects : THEORETICAL <abstract science> b : IMPERSONAL, DETACHED <the abstract compassion of a surgeon -- Time>
4 : having only intrinsic form with little or no attempt at pictorial representation or narrative content <abstract painting>

So what is an abstract class? It can be best described as 1 a : disassociated from any specific instance. An abstract class can not be instantiated. It can have one or more methods that are declared but not defined, these are called abstract methods. When a sub-class extends an abstract class it is the methods within the sub-class that define the abstract methods. If a subclass defines all of the extended abstract methods, then it can be instantiated.

A class must be defined as abstract if it has one or more abstract methods, but doesnt have to have an abstract method to be defined as abstract.

So what is an abstract method? An abstract method has no body, and can only be run when it is defined by a subclass.

NOTE: A class must be declared abstract if it implements an interface but does not define each of the methods within that interface.

Java Keywords

Java reserved keywords are as follows:

abstractbooleanbreakbytecasecatchcharclass
const *continuedefaultdodoubleelseextendsfinal
finallyfloatforgoto *ifimplementsimportinstanceof
intinterfacelongnativenewpackageprivateprotected
publicreturnshortstaticsuperswitchsynchronizedthis
throwthrowstransienttryvoidvolatilewhilestrictfp **

* indicates a keyword that is not currently used

** indicates a keyword that was added for Java 2

Native keyword

The Native keyword is used to include a method within a java class that is implemented in some other programming language, such as C or C++. It is also used to access hardware that is external to the JVM. A Native method has no body and must end with a semi colon. ie: public native String getMake();

Final keyword

The Final keyword is used when you want to create a class that cannot be extended or a method that cannot be overriden in a sub class. Note that an abstract class or method can not be defined as final because this would prevent the abstract class or method from ever being defined.

Transient keyword

Here is what Webster has to say;

Main Entry: 1tran·sient
Pronunciation: -sh(E-)&nt, -zE-&nt, -sE-; -zh&nt, -j&nt
Function: adjective
Etymology: Latin transeunt-, transiens, present participle of transire to go across, pass, from trans- + ire to go -- more at ISSUE
Date: 1599
1 a : passing especially quickly into and out of existence : TRANSITORY b : passing through or by a place with only a brief stay or sojourn
2 : affecting something or producing results beyond itself

A transient field is not part of the serialized form of the object, it has not been written to persistent storage.

Access attributes

Method access attributes

No access attributePermitted access from any class in the same package
privateNo access permitted from outside the class at all
publicPermitted access from any class anywhere
protectedPermitted access from any class in the same package and any sub class anywhere

Note: The default method access attribute is not the same as the protected access attribute.

Garbage Collection

A note on garbage collection: Garbage collection in the JVM is defined by the process of freeing up memory that has been used by the program but is no longer being referenced. The beauty of the Java programming language is that you shouldnt have to worry about garbage collection in your code. If you need to suggest garbage collection you can using System.gc() This however does not force garbage collection, just suggests it.



Copyright 2008 Graham Lange All rights reserved
SUBSCRIBE