lecture20-Objects3

# lecture20-Objects3 - Lecture 20 Objects Scope Encapsulation...

This preview shows pages 1–12. Sign up to view the full content.

Lecture 20: Objects: Scope, capsulation Inheritance Encapsulation, Inheritance CS 170, Section 000 5 November 2009 11/10/2009 CS170, Section 000, Fall 2009 1

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

View Full Document
Lecture Plan ± Review (sort of): Arrays of Objects ± Logistics ± HW6 questions (due tomorrow) ¾ Basic Objects (wrap-up): Ch 9 ¾ Mutability, Scope, this keyword, Encapsulation ¾ if time: StackOfIntegers example (9.8) ¾ Inheritance: Ch 10.1-5 xtending asses per yword method verriding ¾ Extending classes, super keyword, method overriding CS170, Section 000, Fall 2009 2
Logistics Homework 6: Due Wed Nov 11 th Poker simulation Midterm 2: Tuesday, Nov 17 th ¾ Review Session: Monday Nov 16, 4:15-6pm, W301 11/10/2009 CS170, Section 000, Fall 2009 3

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

View Full Document
Array of Objects Circle[] circleArray = new Circle[10]; An array of objects is actually an array of reference variables Invoking circleArray[1].getArea() involves two levels f referencing of referencing circleArray references to the entire array circleArray[1] references to a Circle object. 4
Array of Objects, cont. Circle[] circleArray = new Circle[10]; 5

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

View Full Document
Array of Objects, cont. Compute total area covered by all the circles TotalArea.java 6
Practice problems Basic concept of objects and classes 7.5 Static variables and methods .10, 7.12 7.10, 7.12 Visibility modifiers, accessor and mutator methods 15 7.15 Using Objects in Arrays and methods 7.17, 7.20

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

View Full Document
Lecture Plan ¾ Basic Objects (wrap-up): Ch 9 ¾ Mutability, Scope, this keyword, Encapsulation ¾ if time: StackOfIntegers example (9.8) ¾ Inheritance: Ch 10.1-5 xtending classes super keyword method overriding ¾ Extending classes, super keyword, method overriding CS170, Section 000, Fall 2009 8
Visibility Modifiers and Accessor/Mutator Methods By default, the class, variable, or method can be accessed by any class in the same package. ) public The class, data, or method is visible to any class in any package. ) private he data or methods can be accessed only by the The data or methods can be accessed only by the declaring class. 9

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

View Full Document
Immutable Classes class Student{ rivate ringBuffer rivateName private StringBuffer privateName; Student(String n){ privateName = new StringBuffer(n); } public StringBuffer getName(return privateName); //no “setName” method!

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 54

lecture20-Objects3 - Lecture 20 Objects Scope Encapsulation...

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

View Full Document
Ask a homework question - tutors are online