Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
Beginning Java
about abstract method and class
y bin
Greenhorn
Posts: 4
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 12
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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.
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
overriding.
abstract classes
Confused by answer provided in the Sierra and Bates book - please help
strictfp
Threads: question from jchq
More...