This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design 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: 20945
31
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: 63
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic