19.09.2015 Views

Prentice.Hall.Introduction.to.Java.Programming,.Brief.Version.9th.(2014).[sharethefiles.com]

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter Summary 329<br />

instance 296<br />

instance method 305<br />

instance variable 305<br />

instantiation 296<br />

no-arg construc<strong>to</strong>r 303<br />

null value 305<br />

object 296<br />

object-oriented programming (OOP)<br />

package-private (or packageaccess)<br />

317<br />

private construc<strong>to</strong>r 319<br />

property 296<br />

public class 299<br />

reference type 304<br />

reference variable 304<br />

setter (or muta<strong>to</strong>r) 320<br />

state 296<br />

static method 312<br />

static variable 312<br />

Unified Modeling Language<br />

(UML) 297<br />

CHAPTER SUMMARY<br />

1. A class is a template for objects. It defines the properties of objects and provides<br />

construc<strong>to</strong>rs for creating objects and methods for manipulating them.<br />

2. A class is also a data type. You can use it <strong>to</strong> declare object reference variables. An<br />

object reference variable that appears <strong>to</strong> hold an object actually contains a reference<br />

<strong>to</strong> that object. Strictly speaking, an object reference variable and an object are different,<br />

but most of the time the distinction can be ignored.<br />

3. An object is an instance of a class. You use the new opera<strong>to</strong>r <strong>to</strong> create an object, and<br />

the dot opera<strong>to</strong>r (.) <strong>to</strong> access members of that object through its reference variable.<br />

4. An instance variable or method belongs <strong>to</strong> an instance of a class. Its use is associated<br />

with individual instances. A static variable is a variable shared by all instances of the<br />

same class. A static method is a method that can be invoked without using instances.<br />

5. Every instance of a class can access the class’s static variables and methods. For clarity,<br />

however, it is better <strong>to</strong> invoke static variables and methods using<br />

ClassName.variable and ClassName.method.<br />

6. Modifiers specify how the class, method, and data are accessed. A public class,<br />

method, or data is accessible <strong>to</strong> all clients. A private method or data is accessible<br />

only inside the class.<br />

7. You can provide a get method or a set method <strong>to</strong> enable clients <strong>to</strong> see or modify the<br />

data. Colloquially, a get method is referred <strong>to</strong> as a getter (or accessor), and a set<br />

method as a setter (or muta<strong>to</strong>r).<br />

8. A get method has the signature public returnType getPropertyName(). If<br />

the returnType is boolean, the get method should be defined as public<br />

boolean isPropertyName(). A set method has the signature public void<br />

setPropertyName(dataType propertyValue).<br />

9. All parameters are passed <strong>to</strong> methods using pass-by-value. For a parameter of a primitive<br />

type, the actual value is passed; for a parameter of a reference type, the reference<br />

for the object is passed.<br />

10. A <strong>Java</strong> array is an object that can contain primitive type values or object type values.<br />

When an array of objects is created, its elements are assigned the default value of null.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!