#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2014
    Posts
    22
    Rep Power
    0

    The difference between a class and an object


    Hi Java Professionals,
    is it correct to say a superclass is a class and a subclass is an object?Thanks in advance.
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,737
    Rep Power
    352
    Originally Posted by Loh_jane
    Hi Java Professionals,
    is it correct to say a superclass is a class and a subclass is an object?Thanks in advance.
    Depends on what your instructor has told you.
    I think of an object as an execution time item and a class as a compile time definition.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Location
    Manila, Philippines
    Posts
    33
    Rep Power
    6
    A class is a blueprint of an object. It is where objects are created from.

    Comments on this post

    • alteclansing110 agrees
    Help first. Criticize second.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2016
    Posts
    6
    Rep Power
    0
    Hey,here are few points I am sharing:
    Object:
    -Object is an instance of a class.
    -Object is a physical entity.
    -Object is created many times as per requirement.
    -Object allocates memory when it is created.
    Class:
    -Class is a blueprint or template from which objects are created.
    -Class is a logical entity.
    -Class is a group of similar objects.
    -Class is declared once.
    -Class doesn't allocated memory when it is created.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2016
    Posts
    7
    Rep Power
    0
    The folks above explained it pretty well, I will just add this: You can have 100000 objects of a single class. You can only have one class of a certain type.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Location
    India
    Posts
    200
    Rep Power
    6
    It seems that everybody has explained it and you should have understood it correctly. But just to answer your question:

    is it correct to say a superclass is a class and a subclass is an object?
    The answer is No. When you're talking about subclass and superclass, you're talking Inheritance and that is far from the scope of your question.

    From The Java Tutorials (https://docs.oracle.com/javase/tutor...classes.html):

    A class that is derived from another class is called a subclass (also a derived class, extended class, or child class). The class from which the subclass is derived is called a superclass (also a base class or a parent class).

IMN logo majestic logo threadwatch logo seochat tools logo