IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Cross Ref Guide
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesJava  Print This     

Abstraction (Java and Delphi Cross Reference Guide)

By Mike Prestwood

Java versus Delphi: A side by side comparison between Java and Delphi.

 
OOP Details
 

More object oriented (OO) stuff.

Abstraction

[Other Languages] 

General Info: Abstract Class / Abstract Member

An abstract class member is a member that is specified in a class but not implemented. Classes that inherit from the class will have to implement the abstract member. Abstract members are a technique for ensuring a common interface with descendant classes. An abstract class is a class you cannot instantiate. A pure abstract class is a class with only abstract members.

Languages Focus

Abstraction is supported at various levels with each language. A language could enforce abstraction at the class level (either enforcing a no-instantiation rule or a only abstract members rule), and with class members (member methods and/or properties).

Java:   abstract

Java supports marking a full class as abstract as well as class members. A subclass must either implement the abstract members or you must declare the subclass abstract (which delays the implementation to it's subclass).

Syntax Example:
public abstract class Dog {
  abstract void Bark();
}
Delphi:   abstract, override

Delphi for Win32 supports abstract class members using the abstract keyword. You can even instantiate instances of a class that contains abstract members. Then you override each abstract member in a descendant class with Override.

Delphi does not support setting an entire class as abstract. You can create an abstract class (a class with one or more abstract methods), but there is no way to tell the compiler to not allow the instantiation of the abstract class.

Delphi does not support abstract member properties directly. To implement an abstract properity, make use of abstract methods. That is, you can read a GetPropertyX abstract function and write to a SetPropertyX abstract procedure. In effect, creating  an abstract property.

Syntax Example:
TCyborg = class(TObject)
public
  procedure Speak(pMessage: String); virtual; abstract;
  procedure Walk; virtual; abstract;
end;
 
TSeries600 = class(TCyborg)
public
  procedure Speak(pMessage: String); override;
  procedure Walk; override;
end;












Sales Website: www.prestwood.com Or visit our legacy sales site: 
legacy.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]