This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use of abstract keyword

 
leela krishhna
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20758
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ramesh Pramuditha Rathnayake
Ranch Hand
Posts: 178
2
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only difference is, you can't create instances of class Foo directly.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic