ch02 - 2 Declarations and Access Control CERTIFICATION...

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

View Full Document Right Arrow Icon
2 Declarations and Access Control CERTIFICATION OBJECTIVES Declarations and Modifiers Declaration Rules Interface Implementation Two-Minute Drill Q&A 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
W e’re on a roll. We’ve covered the fundamentals of keywords, primitives, arrays, and variables. Now it’s time to drill deeper into rules for declaring classes, methods, and variables. We’ll tackle access modifiers, abstract method implementation, interface implementation, and what you can and can’t return from a method. Chapter 2 includes the topics asked most often on the exam, so you really need a solid grasp of this chapter’s content. Grab your caffeine and let’s get started. CERTIFICATION OBJECTIVE Declarations and Modifiers (Exam Objective 1.2) Declare classes, nested classes, methods, instance variables, static variables, and automatic (method local) variables making appropriate use of all permitted modifiers (such as public , final , static , abstract , and so forth). State the significance of each of these modifiers both singly and in combination, and state the effect of package relationships on declared items qualified by these modifiers. When you write code in Java, you’re writing classes. Within those classes, as you know, are variables and methods (plus a few other things). How you declare your classes, methods, and variables dramatically affects your code’s behavior. For example, a public method can be accessed from code running anywhere in your application. Mark that method private , though, and it vanishes from everyone’s radar (except the class in which it was declared). For this objective, we’ll study the ways in which you can modify (or not) a class, method, or variable declaration. You’ll find that we cover modifiers in an extreme level of detail, and though we know you’re already familiar with them, we’re starting from the very beginning. Most Java programmers think they know how all the modifiers work, but on closer study often find out that they don’t (at least not to the degree needed for the exam). Subtle distinctions are everywhere, so you need to be absolutely certain you’re completely solid on everything in this objective before taking the exam. 2 Chapter 2: Declarations and Access Control
Background image of page 2
Declarations and Modifiers (Exam Objective 1.2) 3 Class Declarations and Modifiers We’ll start this objective by looking at how to declare and modify a class. Although nested (often called inner ) classes are on the exam, we’ll save nested class declarations for Chapter 8. You’re going to love that chapter. No, really . Seriously. No kidding around. Before we dig into class declarations, let’s do a quick review of the rules: There can be only one public class per source code file. The name of the file must match the name of the public class.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
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.

Page1 / 85

ch02 - 2 Declarations and Access Control CERTIFICATION...

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