Question

Java Question 1. Create a POJO Class (Employee) with these properties: i. ID ii. Age iii....

Java Question

1. Create a POJO Class (Employee) with these properties:

i. ID

ii. Age

iii. Name

2. Write the class to read into the memory. (Reader to read into the memory).

3. Write a Junit test for the Employee class.

Homework Answers

Answer #1

Employee Class:


class employee// class as asked
{
    public String id;
    public int age;
    public String name;
    
    employee(String id, int age, String name)
    {
        this.id=id;
        this.name=name;
        this.age=age;
    }
    
    
    public static void main (String[] args) throws Exception// main program that test the class 
    {
        employee e=new employee("12345",21,"Jack");
        String name="Jack";
        String id="12345";
        Integer age=21;
        System.out.println(name.equals(e.name));
        System.out.println(id.equals(e.id));
        System.out.println(age.equals(e.age));
    }
}

Junit Test:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
This program is in C++: Write a program to allow the user to: 1. Create two...
This program is in C++: Write a program to allow the user to: 1. Create two classes. Employee and Departments. The Department class will have: DepartmentID, Departmentname, DepartmentHeadName. The Employee class will have employeeID, emploeename, employeesalary, employeeage, employeeDepartmentID. Both of the above classes should have appropriate constructors, accessor methods. 2. Create two arrays . One for Employee with the size 5 and another one for Department with the size 3. Your program should display a menu for the user to...
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
Write the following problem in Java Create a class Dog, add name, breed, age, color as...
Write the following problem in Java Create a class Dog, add name, breed, age, color as the attributes. You need to choose the right types for those attributes. Create a constructor that requires no arguments. In this constructor, initialize name, breed, age, and color as you wish. Define a getter and a setter for each attribute. Define a method toString to return a String type, the returned string should have this information: “Hi, my name is Lucky. I am a...
QUESTION 1: This question is also to be used for the next question. Design an Employee...
QUESTION 1: This question is also to be used for the next question. Design an Employee class for a hotel for use in programs. We need an Employee object with these attributes: Name Designation (ex. Manager, Supervisor, Waiter, Bellhop, etc.) ID number Some details: ID Numbers should already be known at time of object's creation. Assume it is an 8 digit number. The ID Number can never be changed Use strings to represent the Name and Designation It is possible...
Create a class Student with the states (attributes): Name, address, phone number, Student ID. Also define...
Create a class Student with the states (attributes): Name, address, phone number, Student ID. Also define the behavior of student as learn, perform assignment, read, attendance, do presentation (Exemple: My name is {Name}). After that create 3 instances of the class Student and present the instance (My name is .....)  
JAVA Question a) Read a file named testScoreIn.txt representing test scores for a class of students....
JAVA Question a) Read a file named testScoreIn.txt representing test scores for a class of students. Each record contains an id number and three test scores (Note: the test scores are integers). For example, a student record might look like: BK1234 87 72 91 b) Without using an array, read each student’s information, one record at a time and compute the student’s average (as a double). c) Write to an output file, testScoreOut.txt, as a neatly formatted table with column...
Create a class called Employee that contains three instance variables (First Name (String), Last Name (String),...
Create a class called Employee that contains three instance variables (First Name (String), Last Name (String), Monthly Salary (double)). Create a constructor that initializes these variables. Define set and get methods for each variable. If the monthly salary is not positive, do not set the salary. Create a separate test class called EmployeeTest that will use the Employee class. By running this class, create two employees (Employee object) and print the annual salary of each employee (object). Then set the...
JAVA. The question mentioned was: Create a class called Point that represents a point in the...
JAVA. The question mentioned was: Create a class called Point that represents a point in the cartesian coordinate system. The class should have fields representing the x coordinate and y coordinate (both are integer type). Question I need an answer to: Write a client class that would create two objects in the Point class above called p1 and p2 and assigns values to the filed in these objects. Print out the x coordinate followed by x comma and last coordinate...
C Programming: Create a struct named “Student” along with 3 properties, Name, ID, Score Choosing the...
C Programming: Create a struct named “Student” along with 3 properties, Name, ID, Score Choosing the correct data type for each property. Once the program is running, it will check if the student.bin file is exist and if it is not exist, the program will ask user to enter three student information and save them to file student.bin . If the file is exist, read the second student information and print it in console.
Using Java: 1. Create a Chapter class with a Chapter title and a number of pages...
Using Java: 1. Create a Chapter class with a Chapter title and a number of pages 2. Create a test chapters class that creates single chapters and arrays of chapters and prints them out
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT