Previous Topic Next topic Print topic


Interfaces - in COBOL and Java

Interfaces in Managed COBOL

*> Accessibility keywords
public
private
internal
protected
protected internal
static
 
*> Inheritance
class-id FootballGame inherits type Competition.
  ...
end class.
*> Interface definition
interface-id IAlarmClock.
  ...
end interface.
 
*> Inheriting an interface 
interface-id IAlarmClock inherits type IClock.
  ...
end interface.
 
*> Interface implementation
class-id WristWatch implements type IAlarmClock, type ITimer.
   ...
end class. 

Interfaces in Java

// Accessibility keywords 
public
private

protected

static

	 
// Inheritance
class FootballGame extends Competition 
{
  ...
}
	 
	 
// Interface definition
interface IAlarmClock 
{
  ...
}
	 
// Extending an interface
interface IAlarmClock extends IClock 
{
  ...
}
	 
	 
// Interface implementation
class WristWatch implements IAlarmClock, ITimer 
{
   ...
}

Portions of these examples were produced by Dr. Frank McCown, Harding University Computer Science Dept, and are licensed under a Creative Commons License.

Previous Topic Next topic Print topic