Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Concrete class

 
jacob deiter
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a class is Concrete class then it should extend a class??

For Example

Class A
{
}

Class B
{
A a=new A();
}

can I say Class A and B a Concrete class???
 
Paul Clapham
Sheriff
Pie
Posts: 20719
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it just shouldn't be an abstract class.

Every class you write is going to extend some other class. Often it will extend Object, but that's still extending a class.
 
John de Michele
Rancher
Posts: 600
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jacob:

Not necessarily (other than the obligatory extension of Object). Any class that's not abstract is concrete. Usually, though, the term means that either the class is extending an abstract class, or is implementing an interface.

John.
 
Campbell Ritchie
Sheriff
Posts: 48363
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would stick to Paul's definition: not abstract. You might say "concrete" to distinguish it from "abstract" but neither extending nor implementing makes a class any more "concrete."
 
W. Joe Smith
Ranch Hand
Posts: 710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:I would stick to Paul's definition: not abstract. You might say "concrete" to distinguish it from "abstract" but neither extending nor implementing makes a class any more "concrete."


Would that be the same as saying you can make an instance of the class? I thought the primary difference between abstract and "concrete" classes was that "concrete" classes could be instantiated whereas abstract classes could not.
 
Campbell Ritchie
Sheriff
Posts: 48363
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not quite. You can't instantiate an abstract class, but there are some concrete classes which cannot be instantiated either. Example: java.lang.Math.
Any class you can create an instance of, however, is concrete.
 
W. Joe Smith
Ranch Hand
Posts: 710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Not quite. You can't instantiate an abstract class, but there are some concrete classes which cannot be instantiated either. Example: java.lang.Math.
Any class you can create an instance of, however, is concrete.


Ah, that makes sense.
 
Campbell Ritchie
Sheriff
Posts: 48363
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
W. Joe Smith wrote:Ah, that makes sense.
That's unusual for one of my posts
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic