function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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.');
    } 
}