+ Start a Discussion
balaji Jayararmanbalaji Jayararman 

How many classes can be extended in the extending class in apex?

Raj VakatiRaj Vakati
You can extend only one class .. but you can implement may class 
 
public virtual class Marker {
    public virtual void write() {
        System.debug('Writing some text.');
    }

    public virtual Double discount() {
        return .05;
    }
}


Then create the YellowMarker class, which extends the Marker class.
 
// Extension for the Marker class
public class YellowMarker extends Marker {
    public override void write() {
        System.debug('Writing some text using the yellow marker.');
    } 
}



Now you can event your AnotherMarker that extends YellowMarker
 
// Extension for the Marker class
public class OtherMarker extends YellowMarker {
    public override void write() {
        System.debug('Writing some text using the yellow marker.');
    } 
}



THIS IS NOT POSSABLE
 
// Extension for the Marker class
public class OtherMarker extends YellowMarker, Marker{
    public override void write() {
        System.debug('Writing some text using the yellow marker.');
    } 
}