• 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

about abstract method and class

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
    Bookmark Topic Watch Topic
  • New Topic