Personal tools
You are here: Home Comp 170 Introduction to OOP Lab Materials Lab13 Concepts
Document Actions

Concepts

by Mit Patel last modified 2006-04-18 11:38 PM

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.

« June 2023 »
Su Mo Tu We Th Fr Sa
123
45678910
11121314151617
18192021222324
252627282930
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: