An annotation is a marker which associates information with a program construct, but has no effect at run time.
Annotations may appear before types or declarations. It is possible for them to appear in a place where they could apply to both a type or a declaration. What exactly an annotation applies to is governed by the "meta-annotation" @Target . See "Defining annotation types" for more information.
publicclassVehicle {publicvoiddrive() {System.out.println("I am driving"); }}classCarextendsVehicle {// Fine @Overridepublicvoiddrive() {System.out.prinln("Brrrm, brrm"); }}// Abstract ClassesabstractclassAnimal {publicabstractvoidmakeNoise();}classDogextendsAnimal {// Fine @OverridepublicvoidmakeNoise() {System.out.prinln("Woof"); }}// this will throw an errorclassLogger1 {publicvoidlog(String logString) {System.out.prinln(logString); }}classLogger2 {// This will throw compile-time error. Logger2 is not a subclass of Logger1.// log method is not overriding anything @Overridepublicvoidlog(String logString) {System.out.println("Log 2"+ logString); }}