Sams Teach Yourself C in 21 Days

(singke) #1

Bonus Day 5 Programming Java Applets


BONUS WEEK


Working with Java


Classes and Methods


Classes are to Java programming as feet are to walking—you cannot take a sin-
gle step without them. A large part of your Java programming effort will be
devoted to creating your own classes to perform the custom tasks that your
application requires. Today you will learn


  • How to define a class

  • How to create class properties and methods

  • How to define packages

  • How to use inheritance


Defining a Class ..................................................................................................


A class definition has several parts, some of which are optional. You have
already seen the basics of defining a class when you created the demo programs
on Bonus Day 4. In Java, everything—including a program—is a class.
However, most Java classes are not programs but are used in programs, and

40 448201x-Bonus5 8/13/02 11:23 AM Page 723

Free download pdf