• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

problem in running abstract class

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


F:\scjp>javac child.java
child.java:6: child is not abstract and does not override abstract method

display() in child
public class child extends parent{
^
child.java:7: abstract methods cannot have a body
public abstract void display(){
^
2 errors

What is this error?
 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



public class child extends parent{
public abstract void display(){
System.out.println("parent");
}
..



You should remove the abstract modifier from the child class' display() method...

To further elaborate, the error occured because the compiler may have interpreted the code as either creating a plain abstract method or implementing an abstract method.

If the child's method display() is marked abstract it should have no body and the child class should be marked abstract too. If that is the case the next concrete subclass of child (class that's not marked abstract) have to implement all the abstract methods up the inheritance tree.

Should you choose just to provide the abstract method implementation of the class parent's display() method, then just removing the abstract modifier will be enough.

Hope this helps.
[ August 15, 2008: Message edited by: Denise Saulon ]
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do not mark the child class method abstract, since you are implementing it.
 
babul bansal
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well this is a blunder mistake

Thanks for correcting me.
 
babul bansal
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well this is a blunder mistake

Thanks for correcting me.
 
"I know this defies the law of gravity... but I never studied law." -B. Bunny Defiant tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic