ch02 - 2 Declarations and Access Control CERTIFICATION...

Info icon This 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
Image of page 1

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

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

Info iconThis 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