Algorithms and OOD (CSC 207 2014F) : EBoards

CSC 207 2014F: Review Session, Week 1


Overview

Could You Throw More Light on Polymorphism, Inheritance, and Encapsulation?

Polymorphism

Inheritance

Encapsulation

What happens if we decide that we should represent points with radius and angle?

    public class Point
    {
      // +--------+------------------------------------------------------
      // | Fields |
      // +--------+

      double radius;
      double theta;

      // +---------+-----------------------------------------------------
      // | Methods |
      // +---------+

      public double distanceFromOrigin()
      {
        return radius;
      } // distanceFromOrigin
    } // class Point

Basic Java Program Structure