A Guide To Advanced Java - Annotations doc

1 186 0
A Guide To Advanced Java - Annotations doc

Đang tải... (xem toàn văn)

Thông tin tài liệu

A Guide To Advanced Java Assignments © 2007 Aptech Ltd Version 1.0 Page 1 of 1 A A n n n n o o t t a a t t i i o o n n s s Sr. No Assignment Question 1. Create an application which uses standard and class level custom annotations to store metadata about an employee. The application accepts the details of an employee from the user and displays them on the screen. The application consists of the following classes: Employee.java The Employee class represents a typical employee record. It stores the following details about an employee: • name • dateOfBirth • currentSalary • designation The Employee class defines two methods to display the details of the employee. The first method is the showEmployeeDetails() method which displays all the details of the employee. The second is the display() method which displays a message that the method is deprecated. Declare this method to be deprecated using annotations. Manager.java The Manager class extends from the Employee class. The class defines a parameterized constructor to create a new instance of the Manager class. It overrides the showEmployeeDetails() method from the Employee class. The override annotation is used to check if the method has been overridden properly or not. Use two class level annotations, one named StringValue to store metadata about a manager and the other named Description to store a description about the Manager class. Administrator.java This class creates instances of the Employee and Manager classes and also defines the StringValue and Description annotations. The class attempts to invoke the deprecated method on the instance of the Employee class. It accepts the details of a Manager and creates an instance of the Manager class with the details. The overridden method showEmployeeDetails() is then invoked on the instance of the Manager class. A class level annotation is also defined for the Administrator class. All the annotations from the Manager class are retrieved and stored in an array of Annotations. Finally, the annotations from the array and the Administrator class are displayed. . instance of the Manager class. A class level annotation is also defined for the Administrator class. All the annotations from the Manager class are retrieved and stored in an array of Annotations. . the Manager class. Administrator .java This class creates instances of the Employee and Manager classes and also defines the StringValue and Description annotations. The class attempts to invoke. standard and class level custom annotations to store metadata about an employee. The application accepts the details of an employee from the user and displays them on the screen. The application

Ngày đăng: 02/08/2014, 08:21

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan