ch05 - 5 Object Orientation, Overloading and Overriding,...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 5 Object Orientation, Overloading and Overriding, Constructors, and Return Types CERTIFICATION OBJECTIVES • Benefits of Encapsulation • Overridden and Overloaded Methods • Constructors and Instantiation • Legal Return Types ✓ Two-Minute Drill Q&A Self Test T he objectives in this section revolve (mostly) around object-oriented (OO) programming including encapsulation, inheritance, and polymorphism. For the exam, you need to know whether a code fragment is correctly or incorrectly implementing some of the key OO features supported in Java. You also need to recognize the difference between overloaded and overridden methods, and be able to spot correct and incorrect implementations of both. Because this book focuses on your passing the programmer’s exam, only the critical exam-specific aspects of OO software will be covered here. If you’re not already well versed in OO concepts, you could (and should) study a dozen books on the subject of OO development to get a broader and deeper understanding of both the benefits and the techniques for analysis, design, and implementation. But for passing the exam, the relevant concepts and rules you need to know are covered here. (That’s a disclaimer, because we can’t say you’ll be a “complete OO being” by reading this chapter.) (We can say, however, that your golf swing will improve.) We think you’ll find this chapter a nice treat after slogging your way through the technical (and picky) details of the previous chapters. Object-oriented programming is a festive topic, so may we suggest you don the appropriate clothing—say, a Hawaiian shirt and a party hat. Grab a margarita (if you’re new to OO, maybe nonalcoholic is best) and let’s have some fun! (OK so maybe we exaggerated a little about the whole party aspect. Still, you’ll find this section both smaller and less detailed than the previous four.) (And this time we really mean it.) CERTIFICATION OBJECTIVE Benefits of Encapsulation (Exam Objective 6.1) State the benefits of encapsulation in object-oriented design and write code that implements tightly encapsulated classes and the relationships IS-A and HAS-A. Imagine you wrote the code for a class, and another dozen programmers from your company all wrote programs that used your class. Now imagine that you didn’t like the way the class behaved, because some of its instance variables were being set (by 2 Chapter 5: Object Orientation, Overloading and Overriding, Constructors, and Return Types the other programmers from within their code) to values you hadn’t anticipated. Their code brought out errors in your code. (Relax, this is just hypothetical…) Well, it is a Java program, so you should be able just to ship out a newer version of the class, which they could replace in their programs without changing any of their own code....
View Full Document

This note was uploaded on 09/17/2009 for the course CMPE 126 taught by Professor Gpour during the Fall '07 term at San Jose State University .

Page1 / 59

ch05 - 5 Object Orientation, Overloading and Overriding,...

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

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