Custom Annotation

1. Program

//What will be the O/P ?

@interface F { public String someMessage(); } class G { //Annotation @F(someMessage="my first method") public static void main(String args[]) { System.out.println("hello world"); } }

2. Program

//What will be the O/P ?

@interface Someinfo{ public String someMessage(); } @Someinfo(someMessage="some desc") class H { @Someinfo(someMessage="about i") int i; @Someinfo(someMessage="about con") H() { } @Someinfo(someMessage="about main") public static void main(String[] arg) { System.out.println("Java"); } }

3. Program

//What will be the O/P ?

@interface Counter{ public int count(); } @Counter(count=3) class I { @Counter(count=5) int i; @Counter(count=10) I() { } @Counter(count=10) public static void main(String[] arg) { System.out.println("hiiii"); } }

4. Program

// What will be the O/P ?

@interface Test { public String message(); public boolean flag(); } @Test(message="some info",flag=true) class J { @Test(message="attribute",flag = false) int i; @Test(message="con",flag=true) J() { } @Test(message="main",flag=true) public static void main(String[] arg) { System.out.println("HEllO world"); } }

5. Program

//What will be the O/P ?

@interface Ann2 { public String message() default "abc"; public int countValue() ; } @Ann1(countValue=9) class L { @Ann2(someMessage="hello") public static void main(String[] arg) { System.out.println("HEllO world"); } }