wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes about abstract method and class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "about abstract method and class" Watch "about abstract method and class" New topic
Author

about abstract method and class

y bin
Greenhorn

Joined: Feb 18, 2004
Posts: 4
I want to determine if the following is correct.
Anybody could discuss it with me?

1,the abstract method's announce need not {} ?
but the abstract method in the abstrct class may have contents({})

2, the abstrct class can't be instantiated, how can I say it has constructor? what is the construtor use?
Leo Deegan
Greenhorn

Joined: Jun 15, 2004
Posts: 12
Hey there, y.

1. An abstract method cannot have a block for its body (that is, it can only use a semicolon and cannot use { }).

2. An abstract class can be instantiated, provided its abstract methods are implemented when the class is instantiated. For instance,

public abstract class Abc {
public astract boolean foo();
}

can be instantiated like this:

Abc abc =
new Abc() {
public boolean foo() {
return false;
}
};

One reason for providing a constructor for an abstract class is that its subclasses may take advantage of the constructor.
 
jQuery in Action, 2nd edition
 
subject: about abstract method and class
 
Similar Threads
Confused by answer provided in the Sierra and Bates book - please help
Threads: question from jchq
strictfp
overriding.
abstract classes