This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
A class that is missing definitions for one or more methods. You can't thus create an object of that class. You must first create a subclass and provide definitions for the abstract methods. Unlike interfaces, abstract classes may implement some of the methods. Though you can't instantiate an abstract class, you can invoke its static methods.
the definition found here is wrong: an abstract class does not need to have an abstract method. it can also have no methods at all or only non-abstract methods.
An abstract class is one that is defined as abstract, which is taken to mean that it is incomplete. More often than not, an abstract class will have one or more abstract methods. A 'real' class may extend an abstract class and provide an implementation for the abstract methods.
this is why I hate "hello World" it doesn't demosrate WHY you want to use java, when you can produce the same result with on line in BASIC??
this explain the follow is incomplete butI think demostrates the concept
your creating an "animal farm" program, and on this farm you have horses,cows,ducks and gease. Horses and cows are mammals, ducks and gease are fouls
so.....
public abstract class Mammal{ public void giveBirth(){.....}
}
public abstract class Foul { public void layEggs() {....} }
then ...
public class Cow extends Mammal ... public class Duck extends Foul.... etc
the point is that even though a duck is a Foul you've never shot a "Foul"
so you can not create a "new Foul" but by creating the abstract class and extending it, then you don't have reprogram the layEggs meathod for every Foul type you make
Originally posted by Robby Robson: this is why I hate "hello World" it doesn't demosrate WHY you want to use java, when you can produce the same result with on line in BASIC??
Ah, but "Hello World!" is not meant to demonstrate that. Rather, it's only meant to teach you how the JVM kicks off your program -- its entry point. Many people find it easier to learn if they add one new concept at a time to what they already know instead of dumping it all in at once.