Java Exam 2 Review

From Knowledge Kitchen
Jump to navigation Jump to search


Multidimensional arrays

Object oriented programming (Oop) concepts

Basic object-oriented programming

The theories and practice of each of the so-called 'pillars' of Ooop:

The elements of good object-oriented style

More object-oriented basics

  • instance properties should be private
    • make setters and getters if you want to allow external access to these properties
    • setters often perform validation
  • if you do have setters and getters, use them everywhere you want to set and get, respectively
  • use the 'this' keyword as a prefix when referring to instance properties and methods from within the same class
  • use the class name as a prefix when referring to static properties and methods

Inheritance

Inheritance

  • Child classes inherit properties and methods of parent classes, except...
    • private properties and methods are not inherited, but private properties are accessible via any public getters and setters
    • constructors are not inherited, but are accessible via super
  • use of the super keyword
  • Processing as a case study of inheritance

Usage and syntax

Keywords

  • this
  • super

Useful classes in the Java API