Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Interview-Questions Meaning Of annatations and use
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


ramesh
Meaning Of annatations and use
1 Answer(s)      5 years and 11 months ago
Posted in : Java Interview Questions



Advertisement
View Answers

December 1, 2008 at 12:31 AM


Hi friend,

Annotation is the way of associating the program elements with the meta tags so that the compiler can extract program behavior to support the annotated elements to generate interdependent code when necessary.

It provide data about a program that is not part of the program itself.
They have no direct effect on the operation of the code they annotate.

Annotations have a number of uses, among them:

* Information for the compiler ? Annotations can be used by the compiler to detect errors or suppress warnings.

* Compiler-time and deployment-time processing ? Software tools can process annotation information to generate code, XML files, and so forth.

* Runtime processing ? Some annotations are available to be examined at runtime.

Annotations can be applied to a program's declarations of classes, fields, methods, and other program elements.

Defining an annotation (Annotation type)

public @interface Example {
String showSomething();
}

Annotating the code (Annotation)

Example (showSomething="Hi! How r you")
public void anymethod() {
....
}


Annotation Types: Three types of annotations types are there in java.

* Marker: Like the marker interface, marker annotations does not contain any elements except the name itself.
The example given below clarifies the concept of marker interface.

Example:

public @interface Example{

}

Usage:

@Example
public void anymethod() {
------------
}

* Single-value: This type of elements provide only single value.
It means that these can be represented with the data and value pair or we can use the
shortcut syntax (just by using the value only within the parenthesis).

Example:

public @interface Example{

String showSomething();

}

Usage:

@Example ("Hi ! How r you")
public void anymethod(){

--------

}

* Multi-value or Full-value: These types of annotations can have multiple data members.
Therefore use full value annotations to pass the values to all the data members.

Example:

public @interface Example{

String showSomething();
int num;
String name;

}

Usage:

@Example (showSomething = "Hi! How r you", num=5, name="zulfiqar" )
public void anymethod{

// code here

}

For read more information on Annotations visit to :

http://www.roseindia.net/hibernate/hibernateannotations/hibernate-annotations-tutorial.shtml

http://www.roseindia.net/ejb/Annotations.shtml

Thanks


Related Tutorials/Questions & Answers:
Meaning Of annatations and use - Java Interview Questions
Meaning Of annatations and use  Hi all use of Annatations and exat meaning of annatations we create our own annatations give an Example... or we can use the shortcut syntax (just by using the value only within
why we use ^ operator in sql, and what is the meaning of that operator?
why we use ^ operator in sql, and what is the meaning of that operator?  why we use ^ operator in sql, and what is the meaning of that operator
Advertisements
Meaning of invoice
Meaning of invoice  hello, What is the meaning of invoice?   hii, Invoice is a statement which contains the following listed things. Invoice Number Invoice date Name and address of the person Name and address
what is the meaning of abstract?
what is the meaning of abstract?  what is the meaning of abstract
what is the meaning this coad?
what is the meaning this coad?  what is the meaning this coad? Example Form example form = (Example Form) form
MEANING OF THe CODE IN BOLD LETTERS
MEANING OF THe CODE IN BOLD LETTERS  public static void main(sting args[]) { shape s[] = {new circle(),new rectangle()}; } //HERE SHAPE RECTANGLE AND CIRCLE ARE THREE CLASSES WHICH ARE DEFINED EARLIER IN THE PROGRAM
what is the meaning of this or explain this
what is the meaning of this or explain this  List<Object[]> list=query.list();   Hi Friend, It will return the query values in the form of list. For more information, visit the following link: Hibernate
What is the special meaning of __sleep and __wakeup?
What is the special meaning of __sleep and __wakeup?  What?s the special meaning of _sleep and _wakeup
What?s the special meaning of __sleep and __wakeup?
What?s the special meaning of __sleep and __wakeup?  What?s the special meaning of _sleep and _wakeup
Tattoo Ideas for Girls with Meaning
Tattoo Ideas for Girls with Meaning: Tattoos with deep meaning While many tattoos are just creative work of art, some text tattoos have a deeper meaning. There are many tattoo ideas for girls with meaning. To show pain and distress
the use of ForwardAction
the use of ForwardAction  What is the use of ForwardAction
use forms.
use forms.  How do I use forms
use of annotation.
use of annotation.  for concurrency which annotation can be used
use is of 2
use is of 2  why we use 2 in "Integer.parseInt(str,2);" for binary to decimal conversion..??   ya i got it... because binary contain only two o and 1...so here use 2...same as octal has 8
Use of jQuery
Use of jQuery  What is the use of jQuery?   Hi, jQuery is JavaScript Ajax library. Developer is using it to create rich internet applications. Read at jQuery Tutorial. Thanks
use of jquery
use of jquery  what is a jquery? what is the evalution of jquery?   Hello Friend, Please visit the following link: JQuery Tutorials Thanks
Introduction
be differ in meaning based on different use of uppercase and lowercase letters. Sometime words can differ in meaning with the same words while starts with capital
use of splitpane
use of splitpane  using JSplitPane split pane in three part. 1st in textField 2nd label and 3rd description. in textField we enter the primary key in textField than it show its all two part as label(image) and description of user
Java Use cases
Java Use cases  What are use cases
Green UML
Green UML       green is a LIVE round-tripping editor, meaning that it supports both software engineering and reverse engineering. You can use green to create a UML
How to use Servlet and Ajax?
How to use Servlet and Ajax?  How to use Servlet and Ajax
use of object tag
use of object tag  how to use object tag in html
use of ejb 3.0
use of ejb 3.0  what is use of ejb 3.0
use of return statement
use of return statement  what is the use of return statement
Use of immediate attribute
Use of immediate attribute  What is the use of immediate attribute
What is the use of friend function?
What is the use of friend function?  What is the use of friend function
What is the use of DESC in SQL?
What is the use of DESC in SQL?  What is the use of DESC in SQL
SQL Use
SQL Use       SQL Use... The Tutorial illustrate an example from 'SQL Use'. To understand and grasp the 'SQL Use' we create a database 'komal' using create database keyword
Use of FTPClient
In this section we will discuss about use of FTPClient class with example
What is use of a abstract variable?
What is use of a abstract variable?   Hi, What is use of a abstract variable? thanks
What is use of a abstract variable?
What is use of a abstract variable?   Hi, What is use of a abstract variable? thanks
Advertisements
 

 

 

DMCA.com