notes5

notes5 - Abstract Methods and Classes abstract class...

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

View Full Document Right Arrow Icon
Abstract Methods and Classes abstract class vaporclass{ abstract vapormethod (String name); } The keyword abstract enables you to provide a method prototype in the class body without its implementation. An abstract class can't be instantiated but it can be subclassed and its abstract methods must be overridden with methods whose implementations are provided. Interface : is a purely abstract class i.e. it contains only abstract methods (no implementations). Thus an interface defines a set of methods a class must implement. Any class that implements each of the methods listed in the interface declares that it implements the interface. A class can implement as many interfaces as it needs to. Interface types act like class types. You can declare vars to be of interface type; declare args of methods to accept interface types; return type of a method can be an interface type. E.g. interface scale { static final int BIG = 0, SMALL = 1; void setscale(int size); } class box implements scale { void setscale(int size) { switch(size) { case BIG: case SMALL: } }
Background image of page 1

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

View Full DocumentRight Arrow Icon
E.g. interface Driveable {
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/29/2011 for the course CNT 6707 taught by Professor Ahuja during the Spring '11 term at UNF.

Page1 / 6

notes5 - Abstract Methods and Classes abstract class...

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

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