Concepts
These concepts will help finish the lab assingment.
Abstract method and class:
Abstract class consists of abstract method (method with no implementation); although, it is possible to have constructor as well as some defined methods. Abstract class defines an interface for its subclasses where subclasses implement the methods from the abstract class. Abstract method is not needed in Abstract class.
abstract class Shapes {
int x, y;
void moveTo(int newX, int newY) { ... }
abstract void getName();
}
class Circle extends Shape {
void getName() { //implementation }
}
class Rectangle extends Shape {
void getName() { //implementation }
}
extends
Used when one class wants to inherit something from the other class.
super
The super keyword is used by an object to refer to methods and fields of a class that it has extended.
instanceOf
if (objectA instanceof objectB) -> will yield true if objectA can be upcast to objectB..
this
This is a reference to the current object which can be used to refer to member of a current object from within method or constructor.