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); }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education