Meaningless Drivel is fun!
The moose likes Java in General and the fly likes Use of abstract keyword Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Use of abstract keyword" Watch "Use of abstract keyword" New topic

Use of abstract keyword

leela krishhna

Joined: Aug 24, 2012
Posts: 10
abstract class Foo


What is the use of abstract key word at here,
even though i am not declare any method in this class..
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

The abstract keyword works just the same for this class as for any other abstract class. I suspect you already know what the keyword means, so you'll know what it means in this case too. The compiler won't let you create an instance of the Foo class.

But were you asking why you would want to do that? All I can say is, it's legal in Java to do so. If you want to know why somebody declared a class with no methods to be abstract, you'd have to ask them.
drac yang
Ranch Hand

Joined: Apr 19, 2013
Posts: 62
the use is all there is to it, indicating the class Foo itself is abstract

maybe it would be used the same as the marker interface. nevertheless it's the marker abstract class. maybe.

science belief, great bioscience!
Ramesh Pramuditha Rathnayake
Ranch Hand

Joined: Oct 31, 2012
Posts: 178

The only difference is, you can't create instances of class Foo directly.

I agree. Here's the link:
subject: Use of abstract keyword
It's not a secret anymore!