DEV Community

Discussion on: How I finally understood what a class is

Collapse
gustavoagt profile image
Gustavo Gómez

Nice post, well explained, i like it, if i would teach in a future some OO language i would go back to this post as a reference. I would like to add two little conceptual details.

In Java a default constructor is constructor that gets generated if you don't explicitly create one. That's the reason why you can create and no-param object without creating an explicitly constructor.

Finally, i would like to add that in the above example "chris" works as a reference of an object assigned to an object in memory.

Collapse
chrisvasqm profile image
Christian Vasquez Author

Thanks for the tips, Gustavo.

Regarding the default constructor, I thought it would be a correct way of calling it since that implementation of the Person class does not allow the client of our code to create an object without passing any arguments to it. Would it be better to say "overriding the default constructor"?

Collapse
gustavoagt profile image
Gustavo Gómez

Thanks to you, i really like it as an introduction for classes, you should continue doing this kind of post.

I considered can be called just param-constructor, if we explicitly add no-args-contructor can be called as a overloaded constructor. The Overrinding is not possible for constructors because the behavior strictly belongs to the class.