• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the answer

 
nikunj thakur
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why is this not a compilable abstract class

public abstract class Canine { public Bark speak();}
 
Nik Arora
Ranch Hand
Posts: 652
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nikunj,

Originally posted by nikunj thakur:
why is this not a compilable abstract class

public abstract class Canine { public Bark speak();}


An abstract class should have abstract methods and can have non-abstract method also.In your example the method is not abstract so you are getting the error.

Regards,
Nik
 
Yogesh Baraskar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public abstract class Canine { public Bark speak();}

speak(); // the brackets and then semicolon suggests that it is an abstract method and you should declare it as
public abstract Bark speak();

or else if you dont want to declare method as abstract then make it
public Bark speak(){
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic