Murach's Beginning Java 2

( 6 )

Overview

Never heard of a Murach book? Our name may be new to you, but for 25 years, we've been developing programming books with a single goal in mind: To make each book the BEST one possible on any given programming subject. That's why professional programmers worldwide look to our books for quick, effective training and reference whenever they're working in a new language or environment. As one programmer put it, "I've read other programming books, but none—and I really mean none—are as useful as yours. Your company ...
See more details below
Available through our Marketplace sellers.
Other sellers (Paperback)
  • All (17) from $1.99   
  • New (2) from $60.00   
  • Used (15) from $1.99   
Close
Sort by
Page 1 of 1
Showing All
Note: Marketplace items are not eligible for any BN.com coupons and promotions
$60.00
Seller since 2015

Feedback rating:

(229)

Condition:

New — never opened or used in original packaging.

Like New — packaging may have been opened. A "Like New" item is suitable to give as a gift.

Very Good — may have minor signs of wear on packaging but item works perfectly and has no damage.

Good — item is in good condition but packaging may have signs of shelf wear/aging or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Acceptable — item is in working order but may show signs of wear such as scratches or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Used — An item that has been opened and may show signs of wear. All specific defects should be noted in the Comments section associated with each item.

Refurbished — A used item that has been renewed or updated and verified to be in proper working condition. Not necessarily completed by the original manufacturer.

New
Brand new.

Ships from: acton, MA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
$86.18
Seller since 2008

Feedback rating:

(210)

Condition: New

Ships from: Chicago, IL

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
Page 1 of 1
Showing All
Close
Sort by
Sending request ...

Overview

Never heard of a Murach book? Our name may be new to you, but for 25 years, we've been developing programming books with a single goal in mind: To make each book the BEST one possible on any given programming subject. That's why professional programmers worldwide look to our books for quick, effective training and reference whenever they're working in a new language or environment. As one programmer put it, "I've read other programming books, but none—and I really mean none—are as useful as yours. Your company has made my life a little easier and a lot wealthier." Now, I'm proud to publish this Java book because I truly believe it's the best Java book I've ever read. Too many beginning books make Java tougher than it needs to be (and it's plenty difficult on its own). But by the time you complete this book, I guarantee you'll be able to write object-oriented business applications in Java.
Read More Show Less

What People Are Saying

Donna M. Dean
"At long last, a Java book written with understandable text, ready-to-run code sniplets, and some of the best exercises in print! As a Web Development instructor, I've seen many introductory Java books with text that read like a translated technical specification sheet. This book has a no-nonsense style, with an expert perspective on the big picture - the need to learn the API.

The first five chapters clearly establish all the groundwork for Java, covering OOP foundation topics like exception handling, UML diagrams, encapsulation, inheritance, and polymorphism. Then, it contains numerous standout chapters that should be read by every Java developer because they're totally relevant yet generally obscure from existing texts. To mention just a few: working with dates and times (a necessity for business programmers); graphics (covering numerous Swing components); and JDBC (which is a must-read for every Java developer).

For sure, we will be using this book for our next Java class."
— Donna M. Dean, CTT, Senior Technical Instructor, The Chubb Institute, Villa Park, Illinois

Read More Show Less

Product Details

  • ISBN-13: 9781890774127
  • Publisher: Murach, Mike & Associates, Inc.
  • Publication date: 9/1/2001
  • Edition description: BK&CD-ROM
  • Edition number: 1
  • Pages: 710
  • Product dimensions: 8.08 (w) x 9.98 (h) x 1.57 (d)

Read an Excerpt

Chapter 5: How to work with inheritance and interfaces

Now that you've learned how to code classes that define objects, you're ready to learn how to work with inheritance, interfaces, and other object-oriented features of Java. Although these features are difficult conceptually, they are critical to the effective use of Java. That's why they can't be put off until later in this book.

You don't, however, have to master everything that's presented in this difficult chapter in one reading. Instead, you can focus on the concepts and terms the first time through it. Then, you can refer back to this chapter whenever you need to refresh your memory about concepts, terms, or coding details.

How to work with inheritance ..... 150
An introduction to inheritance ..... 150
How to code a class that inherits the BookOrder class ..... 152
How to code a class that inherits the JFrame class ..... 154
What you should know about polymorphism ..... 154
How to work with the Object class ..... 156
The methods of the Object class ..... 156
How to cast objects ..... 158
How to override the to String method ..... 160
How to override the equals method ..... 162
How to use the Class class to get information about an Object object ..... 164
More skills for coding classes and methods ..... 166
How to code a method that throws an exception ..... 166
How to work with abstract classes and methods ..... 168
How to work with final classes and methods ..... 170
How to work with access modifiers ..... 172
How to use the this keyword ..... 174
How primitive types and objects are passed to a method ..... 176
How to work with interfaces ..... 180
An introduction to interfaces ..... 180
How to code an interface ..... 182
How to implement an interface ..... 184
How to use an interface as an argument ..... 186
How to implement the Cloneable interface ..... 188
How to code classes that are closely related ..... 190
How to code more than one class per file ..... 190
An introduction to nested classes ..... 192
Perspective ..... 194

How to work with inheritance

Inheritance is one of the critical concepts of object-oriented programming and Java programming. It lets you create a class that inherits fields and methods from another class. These fields and methods can be referred to as members.

An introduction to inheritance

Figure 5-1 introduces you to inheritance. To use it, you create a subclass that inherits the public and protected fields and methods from a superclass. In addition, it inherits all superclass members that have no access modifier as long as the superclass and subclass are in the same package. Then, the objects that are created from the subclass can use these members of the superclass. In addition, though, the subclass can define its own methods. It can also define methods with the same names and signatures of methods in the superclass. In that case, the methods of the subclass override the methods in the superclass.

This is illustrated by the first diagram in this figure, which shows a subclass named DiscountBookOrder that inherits the BookOrder class that you were introduced to in the last chapter. Since the DiscountBookOrder class inherits all of the public methods from the BookOrder class, you can call any of those methods from an object created from the DiscountBookOrder class. In addition, though, the DiscountBookOrder class provides three new methods (setPercentOff, getSubtotal, and getPercentOff). It also provides two methods that will override the ones with the same signatures in the BookOrder class (setTotal and getTotal).

The second diagram shows part of an inheritance hierarchy that's taken from the Java API. Although this diagram only shows three levels of inheritance, Java provides for an unlimited number. In addition, this diagram shows that a superclass can have more than one subclass. In this case, the Window superclass has two subclasses, but here again Java provides for an unlimited number. In the Java API, for example, some classes have dozens of subclasses.

As you become more familiar with the classes of the Java API, you'll find that they make widespread use of inheritance. You'll also discover that you have to use inheritance when you create a graphical user interface for an application. In this case, a class that you create inherits the fields and methods from the Java Frame class. You'll see this illustrated in figure 5-3.

If you think you need to use inheritance as you plan the classes for an application, you should make sure that the subclass has an is-a relationship with its superclass. This means that the subclass is a type of the superclass. For instance, a discount book order is a type of book order, and a frame is a type of window.

Incidentally, in this book, we'll primarily use the terms superclass and subclass to refer to the classes in an inheritance hierarchy. However, a superclass can also be called a base or parent class, and a subclass can also be called a derived or child class.

Description

  • Inheritance lets you define a class that inherits all of the public and protected fields and methods of an existing class. Then, the class that inherits the fields and methods is called a subclass, derived class, or child class, while the class that is being inherited is called a superclass, base class, or parent class.
  • In a subclass, you can define fields and methods that aren't in the superclass. You can also define methods that have the same names and signatures as those in the superclass. In that case, the method in the subclass overrides the method in the superclass.
  • Inheritance is used to model an is-a relationship. In other words, inheritance is used when a subclass is a type of the superclass.
  • Inheritance is commonly used in the classes that are in the Java API, so you often need to know what the inheritance hierarchy is as you use Java classes.

How to code a class that inherits the BookOrder class

Figure 5-2 shows how to code the DiscountBookOrder subclass that inherits the BookOrder class as shown in the previous figure. Whenever you create a subclass, you use the extends keyword to indicate that the subclass extends the superclass. Then, you code the instance variables, constructors, and methods for the subclass. As you do that, you can use the super keyword to call the constructors and methods in the superclass.

If you study the code for the DiscountBookOrder class in this figure, you can see that its declaration extends the BookOrder class. Then, it provides four new instance variables, a constructor, three new methods, and two methods that will override methods in the superclass (setTotal and getTotal).

Since a subclass can't inherit constructors, the DiscountBookOrder class must define its own constructor. The constructor for this subclass has three parameters: the book code that indicates the book that's ordered; the quantity of books ordered; and a key code that indicates what (if any) discount should be taken. After the parameter list, the constructor initializes all of the variables in the superclass and the subclass. First, it uses the super keyword to call the constructor for the superclass. This initializes the three instance variables of the superclass. Then, it initializes the three new instance variables by assigning the third parameter to the discountCode variable and by calling the setPercentOff and setTotal methods.

The first two methods in the DiscountBookOrder class set the instance variables of the class. The setPercentOff method sets the percentOff instance variable based on the value of the discountCode instance variable. Then, the setTotal method sets the subtotal and total instance variables. To do that, it uses the super keyword to call the getQuantity and getBook methods of the BookOrder class, and it uses the getPrice method of the Book class to return the price.

The last three methods in the subclass are get methods that return the subtotal, percentOff, and total variables. Because they're so simple, these methods are coded in single lines instead of the expanded format that you're used to seeing.

After the code for this subclass, you can see the code for a driver class named OverrideTest that tests the DiscountBookOrder class. To do that, the driver creates a DiscountBookOrder object and uses its get methods to return the data for the object into a string variable. To return the title and price for the order, the code first calls the getBook method, which returns a Book object, then calls the getTitle and getPrice methods from that object. After all of the data has been returned to the string, the string is displayed in a dialog box.

Now that you've seen how inheritance works, you can ask whether using it makes sense in a case like this. A simple alternative, for example, is to provide for discounts in the BookOrder class itself. To do that, you could add a third parameter to the constructor and adjust the code as needed. Or, you could add a second constructor to that class with a third parameter for the key code. Either way, the coding for the book order application would be simplified.....

Read More Show Less

Table of Contents

Introduction
Section 1: The Essence of Java Programming
Chapter 1: How to get started with Java
Chapter 2: Java language essentials (part 1)
Chapter 3: Java language essentials (part 2)
Chapter 4: How to write object-oriented programs
Chapter 5: How to work with inheritance and interfaces
Chapter 6: How to design and test object-oriented programs
Section 2: More Java Essentials
Chapter 7: How to work with operators and dates
Chapter 8: How to code control statements
Chapter 9: How to work with arrays, strings, and vectors
Chapter 10: How to handle exceptions and debug code
Section 3: Java for Graphical User Interfaces
Chapter 11: How to code a graphical user interface (part 1)
Chapter 12: How to code a graphical user interface (part 2)
Chapter 13: How to work with menus
Chapter 14: How to work with fonts, colors, images, and shapes
Chapter 15: How to develop applets
Section 4: Java for File Input and Output
Chapter 16: An introduction to file input and output
Chapter 17: How to work with text files
Chapter 18: How to work with binary files
Section 5: Advanced Java Skills
Chapter 19: How to use JDBC to work with databases
Chapter 20: How to work with threads
Index
Read More Show Less

Customer Reviews

Average Rating 3
( 6 )
Rating Distribution

5 Star

(2)

4 Star

(1)

3 Star

(0)

2 Star

(1)

1 Star

(2)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 6 Customer Reviews
  • Anonymous

    Posted September 6, 2004

    Not for beginners

    I am using this textbook for my first programming class. It makes absolutely no sense to me. The test bank questions are not covered in the chapter, I don't care what the publisher says. I am having to purchase other books to learn Java, this one is not doing the job.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted July 23, 2003

    A great book for beginners

    Prior to reading this book, I had a little experience working with Visual Basic 6, but I had no experience with Java. Before finding this book, I tried several other books, but I couldn't even use them to figure out how to install the SDK and compile a simple program. Using this book, I had no trouble installing the SDK and running my first Java program. From there, this book taught me the basic syntax of the Java language, how to use Swing components to create a graphical user interface for my programs, how to read and write text files and binary files, and how to use JDBC to work with a database. I found the explanations in this book to be clear and concise, and I found the exercises at the end of each chapter to be helpful in gaining some hands-on experience with these new skills. Overall, I think this is a great book for anyone who is serious about learning Java.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted May 27, 2003

    Poor choice for beginners

    This book is long on explanation, short on examples and walking through developing applications. For a student, it is an extremely difficult book to use because you read many pages of explanation before actually putting what you've learned into practice, making it difficult to put the pieces together. I wouldn't recommend this for students, especially beginners.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted January 18, 2003

    Excellent book

    I am currently pursuing my Masters in Computer Science and this book has been an invaluable resource. My university textbooks are difficult to understand and gloss over (or don't touch) the most pertinent JAVA topics such as nested classes, JDBC, GUI and threads. The university textbooks were a total waste of money because I kept referring back to this book for clarity. While my classmates were struggling, I received an A - thanks to this book. I only wish Ms. Steelman had written a C++ book also.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted May 13, 2002

    Confusing for the Beginner

    I am sure an experienced Java programmer could figure out this book, but some of the examples are hard to understand and not explained in great detail (a MUST for a beginner). How can you call book of the BOOK class an object and not expect people to be confused. She also goes on about this BOOK application, but you will soon find yourself flipping back and forth between pages to figure out what she is doing. I wish she would have gone in greater detail, especially for a Beginner, we need lots of explaination, for example 'Why would we do something' or 'When would we do something' I think Murach and Associates rushed this to print to try to cash in on the cash cow of Java books. At least she explains SWING and JDBC, which most Beginning Java books won't touch.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted July 20, 2001

    This is the best!

    I have been struggling to learn Java on my own with little success. Murach's new Java book brings theory and practice together. Not only is learning easier but I am now understanding the whys and hows. Great sections on polymorphism, Swing and JDBC.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing all of 6 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)