Murach's Java SE 6
How to define and use classes

Once you know how to use classes from the Java API, this chapter gets you started creating your own classes. Then, chapters 7-9 build on these basics to give you a complete set of object-oriented programming skills.

Chapter 6 How to define and use classes
An introduction to classes 178
How classes can be used to structure an application 178
How encapsulation works 180
The relationship between a class and its objects 182
How to code a class that defines an object 184
The code for the Product class 184
How to code instance variables 186
How to code constructors 188
How to code methods 190
How to overload methods 192
How to use the this keyword 194
How to create and use an object 196
How to create an object 196
How to call the methods of an object 198
How primitive types and reference types are passed to a method 200
A ProductDB class that creates a Product object 202
A ProductApp class that uses a Product object 204
How to code and use static fields and methods 206
How to code static fields and methods 206
How to call static fields and methods 208
How to code a static initialization block 210
When to use static fields and methods 210
The Line Item application 212
The console 212
The classes used by the Line Item application 212
The LineItemApp class 214
The Validator class 214
The LineItem class 218




Murach's Java SE 6

Learn more about this book

Add this book to your cart



Our Ironclad Guarantee

First, try our books for 90 days. Then, if you aren't completely convinced that our books are the best ones you've ever used, you can return them for a full refund...no questions asked.