Virtual Class in Apex A class that extends another class inherits all the methods and properties of the extended class. In addition extending class can override the existing virtual methods by using override keyword in the method definition. Overriding a virtual method allows you to provide a different implementation for an existing method. This means that the behavior of a particular method is different based on the object you're calling it. This is referred as polymorphism . just like abstract class, it is not mandatory to override virtual methods. virtual and abstract classes can extends virtual class. Check below code Now open developer console and run below code snippet and observe the logs Marker obj1, obj2; obj1 = new Marker(); // This outputs 'MARKER: writing some text' obj1.write(); obj2 = new BlueMarker(); // This outputs 'BLUEMARKER: writing some text using BlueMarker' obj2.write(); // We get the price of marker // and can call it fr...
Posts
Showing posts with the label Virtual class Salesforce