aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes what is the answer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "what is the answer " Watch "what is the answer " New topic
Author

what is the answer

nikunj thakur
Ranch Hand

Joined: Sep 23, 2007
Posts: 47
why is this not a compilable abstract class

public abstract class Canine { public Bark speak();}
Nik Arora
Ranch Hand

Joined: Apr 26, 2007
Posts: 652
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

Joined: Oct 07, 2007
Posts: 33
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(){
}
 
Don't get me started about those stupid light bulbs.
 
subject: what is the answer
 
Similar Threads
Abstract class - Whetehere sub class should implement all the abstract methods of base class ?
need packages help
abstract method overriding
regarding class definition
classes cannot be marked as protected?????