ch08 - 8 Inner Classes CERTIFICATION OBJECTIVES Inner...

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

View Full Document Right Arrow Icon
8 Inner Classes CERTIFICATION OBJECTIVES Inner Classes Method-Local Inner Classes Anonymous Inner Classes Static Nested Classes Two-Minute Drill Self Test
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Chapter 8: Inner Classes I nner classes (including static nested classes) appear throughout the exam. Although there are no official exam objectives specifically about inner classes, the objectives related to declarations (1.2 and 4.1) and instantiation (6.3) include inner classes. More importantly, the code used to represent questions on virtually any topic on the exam can involve inner classes. Unless you deeply understand the rules and syntax for inner classes, you’re likely to miss questions you’d otherwise be able to answer. As if the exam weren’t already tough enough. This chapter looks at the ins and outs (inners and outers?) of inner classes, and exposes you to the kinds of (often strange-looking) syntax examples you’ll see scattered throughout the entire exam. So you’ve really got two goals for this chapter—to learn what you’ll need to answer questions testing your inner class knowledge, and to learn how to read and understand inner class code so that you can correctly process questions testing your knowledge of other topics. So what’s all the hoopla about inner classes? Before we get into it, we have to warn you (if you don’t already know) that inner classes have inspired passionate love ‘em or hate ‘em debates since first introduced in version 1.1 of the language. For once, we’re going to try to keep our opinions to ourselves here and just present the facts as you’ll need to know them for the exam. It’s up to you to decide how—and to what extent—you should use them in your own development. We mean it. Not even our tone will betray our true feelings about them. (OK, OK, we’ll tell you! We believe they have some powerful, efficient uses in very specific situations, including code that’s easier to read and maintain, but they can also be abused and lead to code that’s as clear as a cornfield maze, and to the syndrome known as “reuseless”… code that’s useless over and over again .) Inner classes let you define one class within another. They provide a type of scoping for your classes since you can make one class a member of another class . Just as classes have member variables and methods , a class can also have member classes . They come in several flavors, depending on how and where you define the inner class, including a special kind of inner class known as a “top-level nested class” (an inner class marked static ), which technically isn’t really an inner class. Because a static nested class is still a class defined within the scope of another class, we’re still going to cover them in this chapter on inner classes. Unlike the other chapters in this book, the certification objectives for inner classes
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the 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 / 35

ch08 - 8 Inner Classes CERTIFICATION OBJECTIVES Inner...

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

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