Question (2) Create a new package (employee2), solve the error and trace the output import employee.Employee; public class employee2 { public static void main(String[] args) { Employee empl = new Employee(); emp1.firstName = "Ali"; empl.lastName = "Omar"; empl.salary = 20000; empl.employeeSalary(); empl.checkEmployeeSalary(emp1.salary, 5000); }

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 16RQ
icon
Related questions
Question
Question (2)
Create a new package (employee2), solve the error and trace the output
import employee.Employee;
public class employee2 {
public static void main(String[] args) {
Employee empl = new Employee();
empl.firstName = "Ali";
empl.lastName = "Omar";
empl.salary = 20000;
empl.employeeSalary();
empl.checkEmployeeSalary(emp1.salary, 5000);
%3D
Transcribed Image Text:Question (2) Create a new package (employee2), solve the error and trace the output import employee.Employee; public class employee2 { public static void main(String[] args) { Employee empl = new Employee(); empl.firstName = "Ali"; empl.lastName = "Omar"; empl.salary = 20000; empl.employeeSalary(); empl.checkEmployeeSalary(emp1.salary, 5000); %3D
public class Application {
public static void main(String[] args) {
Employee empl = new Employee();
empl.firstName = "Ali";
empl.lastName = "Omar";
empl.salary = 20000;
Employee emp2 = new Employee();
emp2.firstName = "Mohamed";
emp2.lastName = "Nour";
emp2.salary = 30000;
System.out.println("-
System.out.printin("-
empl.employeeSalary();
System.out.println("-
empl.checkEmployeeSalary(emp1.salary, emp2.salary);
System.out.printin("-
System.out.println("-
printEmployee(emp2);
System.out.printin("-
Employee employeeArr[] = new Employee[2]:
employeeArr[0] = empl;
employeeArr[1] = emp2;
Application a = new Åpplication();
a.printArrayofEmployee(employeeArr);
Non static (instance) start to call
Static function to print ---------");
");
- Non Static function to print -
--");
Non static (instance) start to call same class
Static function to print --------);
-");
Non Static function to print ----);
System.out.println("-
System.out.printin("-
System.out.printin("Salary : " + Employee.salary);
Employee.employeeSalary();
System.out.printin("--
System.out.println("Salary : " + Employee.firstName);
Employee.checkEmployeeSalary(empl.salary, emp2.salary);
System.out.printin("-
printEmployee(empl);
printArrayofEmployee(employeeArr);}
public static void printEmployee(Employee e) {
System.out.println("Employee name : "+ e.firstName +" " + e.lastName +
Employee Salary : " + e.salary); }
static start to call
-");
Static Attribute and function ----
"):
Non Static Attribute and function
-"):
static start to call same class-
--"):
public void printArrayOfEmployee(Employee e[]) {
for (int i - 0; i < e.length; i++) {
System.out.println("Employee " + (i + 1) + " Name : " + e[i].firstName +
efi].lastName + " Salary : "+ eſi].salary); }
Transcribed Image Text:public class Application { public static void main(String[] args) { Employee empl = new Employee(); empl.firstName = "Ali"; empl.lastName = "Omar"; empl.salary = 20000; Employee emp2 = new Employee(); emp2.firstName = "Mohamed"; emp2.lastName = "Nour"; emp2.salary = 30000; System.out.println("- System.out.printin("- empl.employeeSalary(); System.out.println("- empl.checkEmployeeSalary(emp1.salary, emp2.salary); System.out.printin("- System.out.println("- printEmployee(emp2); System.out.printin("- Employee employeeArr[] = new Employee[2]: employeeArr[0] = empl; employeeArr[1] = emp2; Application a = new Åpplication(); a.printArrayofEmployee(employeeArr); Non static (instance) start to call Static function to print ---------"); "); - Non Static function to print - --"); Non static (instance) start to call same class Static function to print --------); -"); Non Static function to print ----); System.out.println("- System.out.printin("- System.out.printin("Salary : " + Employee.salary); Employee.employeeSalary(); System.out.printin("-- System.out.println("Salary : " + Employee.firstName); Employee.checkEmployeeSalary(empl.salary, emp2.salary); System.out.printin("- printEmployee(empl); printArrayofEmployee(employeeArr);} public static void printEmployee(Employee e) { System.out.println("Employee name : "+ e.firstName +" " + e.lastName + Employee Salary : " + e.salary); } static start to call -"); Static Attribute and function ---- "): Non Static Attribute and function -"): static start to call same class- --"): public void printArrayOfEmployee(Employee e[]) { for (int i - 0; i < e.length; i++) { System.out.println("Employee " + (i + 1) + " Name : " + e[i].firstName + efi].lastName + " Salary : "+ eſi].salary); }
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT