Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (11.9k points)

public virtual class parent {

    public static void doStuff(){system.debug('stuff');} 

}

public class child extends parent{}

When I call

child.doStuff();

I get this error: Method does not exist or incorrect signature: child.doStuff()

Are static methods not inherited in salesforce or am I doing something wrong?

1 Answer

0 votes
by (32.1k points)

Apex is compatible with Java on this. Static methods are not inherited in a strict sense that means no polymorphism.

So, it is better if you access statics through the class and not an instance. It also produces compiler warnings which are definitely very helpful.

You should access statics through the class, not an instance. It also produces compiler warnings.

Browse Categories

...