{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ch05 - 5 Object Orientation Overloading and Overriding...

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

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
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
Image of page 2
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.
Image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern