Posted on    May-07-2015 7:37 AM

 Java Java 
Ratings:
 3 Answer(s)
  449  View(s)
Rate this:

ANkita gupta
ANkita gupta

Total Post:3

Points:15
Posted on    May-07-2015 7:37 AM

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

Mayank Tripathi
Mayank Tripathi

Total Post:807

Points:4035
Posted on    May-07-2015 8:52 AM

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

ANkita gupta
ANkita gupta

Total Post:3

Points:15
Posted on    May-07-2015 10:26 AM

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.

Don't want to miss updates? Please click the below button!

Follow MindStick