Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| |||||||||||
Hibernate - Interview Questions and Answers for 'Annotations' - 28 question(s) found - Order By Newest | |||||||||||
| |||||||||||
Ans. Generics , Enums , Autoboxing , Annotations and Static Import. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   java5   generics   enum   autoboxing   annotations   static import   rare | |||||||||||
Try 1 Question(s) Test | |||||||||||
| |||||||||||
Ans. @Entity @Table @Id @Column @Temporal @Basic @Enumerated @Access @Embeddable @Lob @AttributeOverride @Embedded @GeneratedValue @ElementCollection @JoinTable @JoinColumn @CollectionId @GenericGenerator @OneToOne @OneToMany @ManyToOne @ManyToMany @NotFound | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  hibernate   annotations | |||||||||||
| |||||||||||
Ans. This annotation is added to the auto increment column with the strategy to increment the column value. Usually this is added to the surrogate primary key column and specified with the Database Sequence. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  hibernate   hibernate annotations   @generatedvalue   database sequence | |||||||||||
| |||||||||||
Ans. Suppose that a software group traditionally starts the body of every class with comments providing important information: public class Generation3List extends Generation2List { // Author: John Doe // Date: 3/17/2002 // Current revision: 6 // Last modified: 4/12/2004 // By: Jane Doe // Reviewers: Alice, Bill, Cindy // class code goes here } To add this same metadata with an annotation, you must first define the annotation type. The syntax for doing this is: @interface ClassPreamble { String author(); String date(); int currentRevision() default 1; String lastModified() default "N/A"; String lastModifiedBy() default "N/A"; // Note use of array String[] reviewers(); } The annotation type definition looks similar to an interface definition where the keyword interface is preceded by the at sign (@) (@ = AT, as in annotation type). Annotation types are a form of interface, which will be covered in a later lesson. For the moment, you do not need to understand interfaces. The body of the previous annotation definition contains annotation type element declarations, which look a lot like methods. Note that they can define optional default values. After the annotation type is defined, you can use annotations of that type, with the values filled in, like this: @ClassPreamble ( author = "John Doe", date = "3/17/2002", currentRevision = 6, lastModified = "4/12/2004", lastModifiedBy = "Jane Doe", // Note array notation reviewers = {"Alice", "Bob", "Cindy"} ) public class Generation3List extends Generation2List { // class code goes here } | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   annotations | |||||||||||
| |||||||||||
Ans. @Deprecated annotation indicates that the marked element is deprecated and should no longer be used. The compiler generates a warning whenever a program uses a method, class, or field with the @Deprecated annotation. @Override annotation informs the compiler that the element is meant to override an element declared in a superclass. @SuppressWarnings annotation tells the compiler to suppress specific warnings that it would otherwise generate. @SafeVarargs annotation, when applied to a method or constructor, asserts that the code does not perform potentially unsafe operations on its varargsparameter. When this annotation type is used, unchecked warnings relating to varargs usage are suppressed. @FunctionalInterface annotation, introduced in Java SE 8, indicates that the type declaration is intended to be a functional interface, as defined by the Java Language Specification. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   java8   annotations   pre defined annotations | |||||||||||
| |||||||||||
Ans. Annotations that apply to other annotations are called meta-annotations. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   annotations   meta annotations | |||||||||||
| |||||||||||
Ans. @Retention annotation specifies how the marked annotation is stored: @Documented annotation indicates that whenever the specified annotation is used those elements should be documented using the Javadoc tool. (By default, annotations are not included in Javadoc.) @Target annotation marks another annotation to restrict what kind of Java elements the annotation can be applied to. @Inherited annotation indicates that the annotation type can be inherited from the super class. (This is not true by default.) When the user queries the annotation type and the class has no annotation for this type, the class' superclass is queried for the annotation type. This annotation applies only to class declarations. @Repeatable annotation, introduced in Java SE 8, indicates that the marked annotation can be applied more than once to the same declaration or type use. For more information, see Repeating Annotations. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   java8   annotations   meta annotations | |||||||||||
| |||||||||||
Ans. Using annotation Test with the argument as expected exception. @Test (expected = Exception.class) | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  junit   junit annotations | |||||||||||
| |||||||||||
Ans. Deprecated annotation is for documentation purpose only. It doesn't enforce anything but would mark the method name as crossed to signify that the client should refrain from using it. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  Deprecated annotation | |||||||||||
| |||||||||||
Ans. No. It just marks the method and hence signals the client to refrain from using it. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  Deprecated annotation | |||||||||||
| |||||||||||
Ans. Annotations, a form of metadata, provide data about a program that is not part of the program itself. Annotations 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. • Compile-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. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   annotations basic   frequent | |||||||||||
| |||||||||||
Ans. We configure Entity classes having annotated mappings. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  hibernate   hibernate annotations | |||||||||||
| |||||||||||
Ans. The first annotation will try to map the Class with the Table as of same name as Class whereas the second annotation will specify the Entity name as "EMPLOYEES" and hence will try to map with Table Name "EMPLOYEES". | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  hibernate   hibernate annotations   entity annotations | |||||||||||
| |||||||||||
Ans. First Annotation will set the Entity name as EMPLOYEES and hence will try to map with the same Table name. The second annotation will make the Entity mapped to table EMPLOYEES irrespective of the Entity Name ( which is class name in this case ). Third Annotations will set the different names for Enitity and Table and will explicitly map them. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  hibernate   hibernate annotations   entity annotation   table annotation | |||||||||||
| |||||||||||
Ans. Auto , Identity , Sequence and Table. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  hibernate   generatedvalue annotations   architecture | |||||||||||
| |||||||||||
Ans. Using lazy = false in hibernate config file or @Basic(fetch=FetchType.EAGER) at the mapping | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  hibernate   lazy loading hibernate   basic annotation hibernate   architecture | |||||||||||
| |||||||||||
Ans. @Test The Test annotation indicates that the public void method to which it is attached can be run as a test case. @Before The Before annotation indicates that this method must be executed before each test in the class, so as to execute some preconditions necessary for the test. @BeforeClass The BeforeClass annotation indicates that the static method to which is attached must be executed once and before all tests in the class. @After The After annotation indicates that this method gets executed after execution of each test. @AfterClass The AfterClass annotation can be used when a method needs to be executed after executing all the tests in a JUnit Test Case class so as to clean-up the set-up. @Ignores The Ignore annotation can be used when you want temporarily disable the execution of a specific test. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   junit   jnuit4   junit annotations | |||||||||||
| |||||||||||
Ans. http://www.buggybread.com/2015/01/java-annotations-classes-and-interfaces.html | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   annotations | |||||||||||
| |||||||||||
Ans. @Autowired and @Inject are similar in terms of functionality they achieve. @Inject is part of a new Java technology called CDI that defines a standard for dependency injection whereas @Autowired is a Spring specific annotation for dependency injection. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  spring   web frameworks   dependency injection   autowired   inject   spring annotations   ioc | |||||||||||
| |||||||||||
Ans. Deprecating the interface / or declaration doesn't make much sense as the implementation is deprecated and not the interface. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  Deprecated annotation | |||||||||||
| |||||||||||
Ans. Annotations are used to specify meta information about the code. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  Annotations | |||||||||||
| |||||||||||
Ans. Yes , as both code and its meta information reside in the same file, it promotes better readability and maintenability. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  Annotations | |||||||||||
| |||||||||||
Ans. There are 2 ways to specify dependencies in Spring, one by the way of specifying beans in config files and other is by specifying annotations like @Bean, @Component , @Service etc to let spring know of the dependencies. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  spring bean annotation  spring annotations | |||||||||||
| |||||||||||
Ans. The @Import annotation is used to import one or more @Configuration classes. This annotation provides the functionality equivalent to element in xml based configuration. The @ImportResource annotation is used to import one or more XML configuration files. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  annotations Asked in 1 Companies | |||||||||||
| |||||||||||
This question is still unanswered. Can you please provide an answer. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  annotations  custom annotations basic | |||||||||||
| |||||||||||
Ans. @RequestMappping | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  spring  spring annotations Asked in 1 Companies | |||||||||||
| |||||||||||
Ans. These annotations are used to create Spring beans automatically in the application context. The main stereotype annotation is @Component . @Controller: Which is used to create Spring beans at the controller layer. The stereotype annotations in spring are @Component, @Service, @Repository and @Controller | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  stereotype annotation   stereotype annotation spring Asked in 1 Companies | |||||||||||
| |||||||||||
Ans. @ComponentScan in a Spring Application. With Spring, we use the @ComponentScan annotation along with the @Configuration annotation to specify the packages that we want to be scanned. @ComponentScan without arguments tells Spring to scan the current package and all of its sub-packages. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  ComponentScan  dispatcher  @ComponentScan annotation  @Configuration annotation Asked in 1 Companies | |||||||||||
| |||||||||||
| |||||||||||