Java Reference
In-Depth Information
method We can communicate with objects by invoking methods on them. Objects usually do
something if we invoke a method.
parameter Methods can have parameters to provide additional information for a task.
signature The header of a method is called its signature. It provides information needed to
invoke that method.
type Parameters have types. The type defines what kinds of values a parameter can take.
multiple instances Many similar objects can be created from a single class.
state Objects have state. The state is represented by storing values in fields.
method calling Objects can communicate by calling each other's methods.
source code The source code of a class determines the structure and behavior (the fields
and methods) of each of the objects of that class.
result Methods may return information about an object via a return value.
Exercise 1.30 In this chapter we have mentioned the data types int and String . Java
has more predefined data types. Find out what they are and what they are used for. To do this,
you can check Appendix B, or look it up in another Java book or in an online Java language
manual. One such manual is at
http://download.oracle.com/javase/tutorial/java/nutsandbolts/
datatypes.html
Exercise 1.31 What are the types of the following values?
0
"hello"
101
-1
true
"33"
3.1415
Exercise 1.32 What would you have to do to add a new field, for example one called name ,
to a circle object?
Exercise 1.33 Write the signature for a method named send that has one parameter of
type String , and does not return a value.
Exercise 1.34 Write the signature for a method named average that has two parameters,
both of type int , and returns an int value.
Exercise 1.35 Look at the topic you are reading right now. Is it an object or a class? If it is a
class, name some objects. If it is an object, name its class.
Exercise 1.36 Can an object have several different classes? Discuss.
Search WWH ::




Custom Search