CLASS

ANkita gupta

Total Post:3

Points:15
Posted by  ANkita gupta
Java 
 625  View(s)
Ratings:
Rate this:
  1. ANkita gupta

    Post:3

    Points:15
    Class

    WHAT IS SUBCLASSING? IS IT SAME AS SUBCLASS OR THEIR IS DIFFERENCE?

  1. Mayank Tripathi

    Post:807

    Points:4035
    Class

    Sub classing is done with the help of inheritance. It is done for design purposes


    Suppose you have a Chair class and you want to categories this further under RevolvingChair so, you need to extend the Chair class in RevolvingChair class.
    Now you only need to implement the revolving feature revolve() in your RevolvingChair class, the other chair features will be already included from the parent class i.e.Chair Class

    public Class Chair{
    //chair properties
    // chair behavior and methods
    }

    public class RevlovingChair extends Chair{
    //extra properties for revolving chair, it also includes the properties of Chair class, we don't need to implement it again here.

    // new methods (we don't need to implement chair methods here again)
    revolve()
    }

    For further details:
    http://www.mindstick.com/Articles/2d57f8ff-6a32-416b-8c2f-e5ec44b5a335/Inheritance%20in%20Java#.VUuIYPmqqko 

      Modified On May-07-2015 08:53:47 AM
  1. ANkita gupta

    Post:3

    Points:15
    Class

    we can define subclassing in this manner too

    Subclassing involves creating a new class that inherits from some other class in the class
    hierarchy. Using subclassing, you only need to define the differences between your class
    and its parent; the additional behavior is all available to your class through inheritance.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!