- Understand and create a new class in Java.
- Creating objects and accessing them in a class.
- Creating and invoking methods in Java
- Create constructors.
- Create instances using argument and no-argument constructors.
- Create static variables and methods.
- Invoking static methods.
-
Create a package
com.trainingmug.ecommerce
under/src/main/java
-
Create a new Java class named
Employee
in thecom.trainingmug.ecommerce
package with the following properties:- id :
long
- name :
String
- designation :
String
- grossSalary :
float
- travellingAllowances :
float
- federalTax :
float
- stateTax :
float
- id :
-
Create a no-argument constructor for Employee class to initialize the instance variables to the following.
- id: 111
- name : Andrew Filler
- designation = Senior Software Engineer;
- grossSalary = 5208.33;
- federalTax = 611.86;
- stateTax = 359.24;
-
Create an all-argument constructor for Employee class to initialize the instance variables.
-
Create a method in
Employee
class to display all the property values as follows:public void displayProfile() {}
-
Create a method in Employee class to increase the
grossSalary
by the given percentage as follows:public void incrementSalary(float percentage) {}
-
Add the following static constant variables in Employee class:
- companyName :
String
- companyContactNo :
String
- employeeCount :
long
- companyName :
-
Each time the
Employee
object is created, theemployeeCount
should be incremented by 1. -
Create a static method in
Employee
class to display all the static properties and the method signature as follows:public static void displayCompanyInfo() {}