• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

abstract example

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone give me an example of definition of abstract?
I am trying to prepare for Java Programmer 1.4 test and I am wondering about one explanation given in one Java Certificate book. The book says that "abstract - used to declare a class that cannot be instantiated, or a method that must be implemented by a nonabstract subclass". I would like to see an code example out of the latter definition.
Thanks alot!
-j
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The abstract method has no implementation and all concrete subclasses must provide their own implementations of the method.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An abstract class is one which can be used to define some kind of a template (i.e a generic one)
For eg, we can hav an abstract class shape, which contains methods like
draw() etc which cannot be defined by tht class itself. But classes tht extend this abstract class like square, circle etc can implement this method in their own terms.
Thus an abstract class helps to define a common template which the non-abstract subclasses can use.
(The point is, by making an abstract class reference point to instances of its different non-abstract subclasses we can achieve Runtime polymorphism)
Regarding a non-abstract subclass, it is the subclass of an abstract class, which implements all of the abstract methods of its parent class.
If a subclass of an abstract class decides not to implement all the abstract methods of its parent, then the subclass also shud be declared as abstract (the abv rule holds good for its subclass also).
Hope the abv answer is correct...and it helps
 
Mika Leino
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thunder,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!
 
reply
    Bookmark Topic Watch Topic
  • New Topic