Main Class| ClassA
public virtual class ClassA {
public String myFirstName;
public String myLastName;
public ClassA() {
myFirstName = 'Engin';
myLastName = 'Basturk';
}
public ClassA(String firstName, String lastName) {
myFirstName = firstName;
myLastName = lastName;
}
public virtual void printName() {
System.debug('My name is ' + myLastName);
}
public virtual String getFirstName() {
return myFirstName;
}
}
Sub Class| ClassB
You can create ClassB that extends ClassA
public class ClassB extends ClassA {
public override void printName() {
super.printName();
System.debug('But you can call me ' + super.getFirstName());
}
}
Apex Code
ClassB obj =new ClassB();
obj.printName();
Video
Video does not exists.