05OOPAbstraction

05OOPAbstraction - CMSC 132: Object-Oriented Programming II...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Overview References, alias, levels of copying Constructor, initialization block Garbage collection, destructor Package, scope, inner classes Modifiers Public, Private, Protected Static, Final, Abstract Generic programming
Background image of page 2
Object Abstracts away (data, algorithm) details Encapsulates data Instances exist at run time Class Blueprint for objects (of same type) Exists at compile time
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
“this” Reference Description Reserved keyword Refers to object through which method was invoked Allows object to refer to itself Use to refer to instance variables of object Used in constructor to invoke a different constructor
Background image of page 4
“this” Reference – Example class Node { value val1 ; value val2 ; void foo(value val2 ) { … = val1 ; // same as this.val1 (implicit this) … = val2 ; // parameter to method … = this . val2 ; // instance variable for object bar( this ); // passes reference to object } } Also used in constructors to invoke another constructor in the same class.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Inheritance Definition Relationship between classes when state and behavior of one class is a subset of another class Terminology Superclass / base class More general class Subclass / derived class More specialized class Forms a class hierarchy Helps promote code reuse
Background image of page 6
“super” Reference Description Reserved keyword Refers to superclass Allows object to refer to methods / variables in superclass Examples super.x // accesses variable x in superclass super() // invokes constructor in superclass super.foo() // invokes method foo() in superclass
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Reference A way to get to an object, not the object itself
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 29

05OOPAbstraction - CMSC 132: Object-Oriented Programming II...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online