Apex Reserved keyword

1. Class

This keyword is used to define a class.

Example

private class MyClass {
	private Integer number;
	public Integer getNumber() {
		return number;
	}
}

2. Abstract

This keyword is used to define abstract classes. An abstract class that contains methods only have a signature and no body is defined. Can also define methods.

Example

public abstract class MyAbstrtactClass {
	protected void myMethod1() {
		/* instruction */
	}
	abstract Integer myAbstractMethod1();
}

3. Implements

This keyword is used to declare a class that impediments an interface.

Example

global class CreateTaskEmailExample implements Messaging.InboundEmailHandler {
	global Messaging.InboundEmailResulthandleInboundEmail(Messaging.inboundEmail email,Messaging.InboundEnvelope env) {
		// do some work, return value;
	}
}

4. extends

Defines a class that extends another class.

Example

public class MyClass1 extends MyClass {
    // code
}

5. interface

This keyword is used to define a data type with method signatures. Classes implement interfaces. An interface can extend another interface.

Example

public interface PO {
	public void doWork();
}

public class MyPO implements PO {
	public override doWork() {
		// actual implementation
	}
}

6. virtual

This keyword Defines a class or method that allows extension and overrides. You can’t override a method with the override keyword unless the class or method has been defined as virtual.

Example

public virtual class MyException extends Exception {
	// Exception class member
	// variable
	public Double d;
	
	// Exception class constructor
	MyException(Double d) {
		this.d = d;
	}
	
	// Exception class method
	protected void doIt() {
	
	}
}