• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

what is a concrete class

 
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody..
there are interfaces and abstract classes.Now what is this concrete class.
is concrete class anyway related to the interfaces or abstract class.
please can i get to know this with an example.

Thanks a lot..
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gajendra Kangokar wrote:Now what is this concrete class.


A class that can be instantiated. In general (but not always), this means that you can say:
MyClass m = new MyClass(...);
without getting a compiler error.

Winston
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any class, concrete or abstract can be written to implement an interface. You cannot instantiate a class or interface until you have implementations for all its methods.
 
Ranch Hand
Posts: 384
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A class is called concrete when it defines all the member and inherited methods and which can be instantiated.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Lalit Mehra wrote:A class is called concrete when it defines all the member and inherited methods and which can be instantiated.

Not at all. A class is called concrete when it is not abstract.
 
Lalit Mehra
Ranch Hand
Posts: 384
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Not at all. A class is called concrete when it is not abstract.



Ok. But i think a abstract class cannot be instantiated while a concrete class can be.
A concrete class also gives definition to all the inherited methods and the once which are specific to the concrete class.
Isn't it so ?
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Lalit Mehra wrote:

Campbell Ritchie wrote:Not at all. A class is called concrete when it is not abstract.



Ok. But i think a abstract class cannot be instantiated while a concrete class can be.



You said: "A class is called concrete when it defines all the member and inherited methods and which can be instantiated." The part about "when it defines all the member and inherited methods" is incorrect, or at the very least confusing and unnecessary.

Simply, "A class is called concrete when it is not abstract," exactly as Campbell said, is correct and complete.

A concrete class also gives definition to all the inherited methods and the once which are specific to the concrete class.
Isn't it so ?



I don't know what, if anything, the language spec says about whether a class "defines" methods that it simply inherits from its parents and overrides. Maybe it does, maybe it doesn't, but I can't be bother to look it up. Since it adds nothing to the definition even if it is correct, there's no point.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Lalit Mehra wrote: . . . Ok. But i think a abstract class cannot be instantiated while a concrete class can be.

You can create an anonymous class from an abstract class and instantiate it like that. That is not strictly instantiating the abstract class however.

A concrete class also gives definition to all the inherited methods and the once which are specific to the concrete class.
Isn't it so ?

You can have abstract classes with all methods implemented.

As I said yesterday, a concrete class is one which is not marked abstract. You can have concrete classes which cannot be instantiated, too. An example is java.lang.Math.
The Java Language Specification appears not to use the phrase “concrete class”.
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Gajendra: I hope all this extra discussion isn't confusing you.

The fact is that Campbell is absolutely right, and Lalit and I are wrong (sorry if I misled you with my post): A concrete class is a named class that is not abstract; simple as that.

Winston
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:A concrete class is a named class that is not abstract; simple as that.



Any particular reason for restricting it to named classes? I'm not aware of any official definition, but I would consider anonymous classes to be concrete as well. I've always taken it to mean, simply, "not abstract," as Campbell is saying.
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeff Verdegan wrote:Any particular reason for restricting it to named classes? I'm not aware of any official definition, but I would consider anonymous classes to be concrete as well. I've always taken it to mean, simply, "not abstract," as Campbell is saying.


Yeah, I guess that's the problem. It's one of those terms that crops up a lot, but doesn't seem to have an official definition.

Mine comes from the word "concrete" itself which, even if used metaphorically, means something substantive. To me, an anonymous class is simply an object - it just happens to be defined and instantiated at the same time. It doesn't define a type, and you certainly can't do anything else with it, so to me there's nothing "concrete" about it.

But hey, I quite understand your disagreement.

Winston
 
Gajendra Kangokar
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Winston,
it is bit clear now that a concrete class is a simple non-abstract class where a reference variable of the same can be created to point a new object.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gajendra Kangokar wrote:Yes Winston,
it is bit clear now that a concrete class is a simple non-abstract class where a reference variable of the same can be created to point a new object.



You're overcomplicating it. Reference variables have nothing to do with whether a class is concrete.

Once again: A concrete class is simply a non-abstract class. Or, if you prefer Winston's definition, a non-abstract, non-anonymous class. None of that has any relation to reference variables.
 
Whizlabs Java Support
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gajendra ,

An abstract class is meant to be used as the base class from which other classes are derived. The derived class is expected to provide implementations for the methods that are not implemented in the base class. A derived class that implements all the missing functionality is called a concrete class .

Regards,
James
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

James Peterson wrote:Hi Gajendra ,

An abstract class is meant to be used as the base class from which other classes are derived. The derived class is expected to provide implementations for the methods that are not implemented in the base class. A derived class that implements all the missing functionality is called a concrete class .



By that definition, Child1 and Child2 would be concrete classes, since both are derived from an abstract base class and both implement all the missing functionality from that base class.


So your definition is both more complicated and vague than the ones already provided several times, and doesn't really make any sense.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic