Lecture 15 - Enhanced Class Design

Lecture 15 - Enhanced Class Design - o You must use the...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Enhanced Class Design Abstract Classes and Methods Are denoted with the keyword abstract o Eg public abstract class Shape{ } An abstract class cannot be instantiated o Eg Shape s = new Shape(); // Won’t compile o Expected that concrete subclasses will extend the abstract class An abstract method has no code o Consists of a method signature only, prepended with the keyword abstract o Eg public abstract class Shape { public abstract double area(); ... } o Expected that an overriding method in a concrete subclass will supply an implementation A class that has one or more abstract methods is automatically abstract
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: o You must use the abstract keyword for the class o If a subclass does not implement all abstract methods of its parent(s), it is also abstract o It is common to have a mixture of concrete and abstract methods in an abstract class Abstract Classes and Methods in UML Are denoted in italics Shape + origin : Point; + area() : double Since italics are difficult to hand write, an alternate form uses the <<abstract>> stereotype <<abstract>> Shape...
View Full Document

Page1 / 2

Lecture 15 - Enhanced Class Design - o You must use the...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online