Abstract

subclasses of an abstract class need to provide implementations for any abstract methods that they inherit. A variable declared of a particular class is intrinsically polymorphic: it can designate objects from that class or from any of its direct or indirect subclasses. Objects are generated on the heap from invocations of constructors. Complementing the class concept is the feature known as an interface. An interface may be viewed as a restricted form of class with no “implementation” aspects. Thus the only methods allowed in an interface are abstract methods, and the only variables allowed in an interface are so-called final variables, which are constants. A class is allowed to extend only one class but may implement an arbitrary number of interfaces; in this sense Java provides some support for multiple inheritance. Here is an example of Java’s main OOP concepts, adapted from [4]: public class Point{ protected static int numPts=0; protected int x, y; public Point(int x, int y){ this.x=x; this.y=y; numPts++; } public static int getNumPts(){ return numPts; } public void shift(int ∆x, int ∆y){ x += ∆x; // Note Unicode character

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call