Java Reference
In-Depth Information
1.6
Object-Oriented Programming
SR 1.33
1. Understand the problem.
2. Design a solution.
3. Consider alternatives and refinements to the solution.
4. Implement the solution.
5. Test the solution.
SR 1.34
The first solution to a problem that we think of may not be a good one.
By considering alternative solutions before expending too much energy
implementing our first idea, we can often save overall time and effort.
SR 1.35
The primary elements that support object-oriented programming are
objects, classes, encapsulation, and inheritance. An object is defined
by a class, which contains methods that define the operations on those
objects (the services that they perform). Objects are encapsulated such
that they store and manage their own data. Inheritance is a reuse tech-
nique in which one class can be derived from another.
Chapter 2
Data and Expressions
2.1
Character Strings
SR 2.1
A string literal is a sequence of characters delimited by double quotes.
SR 2.2
Both the
print
and
println
methods of the
System.out
object write a
string of characters to the monitor screen. The difference is that, after
printing the characters, the
println
performs a carriage return so that
whatever's printed next appears on the next line. The
print
method
allows subsequent output to appear on the same line.
SR 2.3
A parameter is data that is passed into a method when it is invoked. The
method usually uses that data to accomplish the service that it provides.
For example, the parameter to the
println
method indicates what char-
acters should be printed.
SR 2.4
The output produced by the code fragment is
One
Two Three
SR 2.5
The output produced by the code fragment is
Ready
Set
Go
Search WWH ::
Custom Search