Tuesday, July 1, 2008

SCJP Exam - Objective 1.2

Develop code that declares an interface. Develop code that implements or extends one or more interfaces. Develop code that declares an abstract class. Develop code that extends an abstract class.

Interface declaration
This is discussed in Objective 1.1 - Interface declaration.

Do not forget, what is in the Objective 1.1 written about interface declarations.

Extend an interface
  • an interface can extend one or more other interfaces

  • an interface cannot extend anything but another interface


Abstract class declaration
abstract class <ClassName> {
//...
}

You can read more about abstract classes in Objective 1.1 - Non-access modifier: abstract.

Extend an abstract class
  • a class can extend only one class (no multiple inheritance)
  • abstract class can extend concrete and abstract classes


Example for interface declaration, interface implementation, abstract class declaration, abstract class extension:

You can download source code here.

No comments: