Knowee
Questions
Features
Study Tools

Review the class Employee example provided in the tutorial.What code segment could be added as a method to return the number of employees managed, if this was kept track in a variable called numManaged?a.)public int getNumManaged(){ return numManaged;}b.)public void getNumManaged(){ return numManaged;}c.)public int getNumManaged(){ return employeesManaged;}d.)public void getNumManaged(int numManaged){ return numManaged;}

Question

Review the class Employee example provided in the tutorial.What code segment could be added as a method to return the number of employees managed, if this was kept track in a variable called numManaged?a.)public int getNumManaged(){ return numManaged;}b.)public void getNumManaged(){ return numManaged;}c.)public int getNumManaged(){ return employeesManaged;}d.)public void getNumManaged(int numManaged){ return numManaged;}

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct code segment to return the number of employees managed would be:

a.) public int getNumManaged(){ return numManaged;}

This is because in Java, getter methods should return a value and therefore must not be declared as void. They are used to read the value of a private variable. In this case, the variable is numManaged. The other options either declare the method as void or try to return a variable that doesn't match with the one we are keeping track of.

This problem has been solved

Similar Questions

Get a count of number of employees. Get the input details from each employee like name, address, designation ,‘section name’ and ‘department’ till that particular count is reached.In the names of the employees   where the pattern “im” occurs. Replace it by ‘is’.Using static member functions/static variable, assign a unique roll number to each employee.Display all the employee details. Implement the above process using java class and constructors.

1. Select four (4) statements taht can be onserted at line n1.CODE:public class Employee { public int salary;}public class Manager extends Employee { public int budget;}public class Director extends Manager { public int stockOptions;} public static void main(String[] args) { Employee employee = new Employee(); Manager manager = new Manager(); Director director = new Director(); //line n1 }}CHOICES:- employee.salary = 50000- director. salary = 80000- employee.budget = 20000- manager.budget = 100000- manager.stockOptions = 500;- director.stockOptions = 1000;

public class Employee {    private String name;        public String getName() {        return name;    }    public void setName(String name) {        this.name = name;    }    public int getSal() {        return sal;    }    public void setSal(int sal) {        this.sal = sal;    }    private int sal;    public Employee(String name,int sal)    {        this.name = name;        this.sal = sal;    }    public String toString()    {        return name+" "+sal;    }    public int applyInc(int percentage)    {        return sal*percentage;    }}EmployeeStarter.java:public class EmployeeStarter {    public static void main(String[] args)     {        Employee employee = new Employee("Sangamithra",30000);  System.out.println(employee.applyInc(2));//calling the method of Employee that doubles the salary        System.out.println(employee.applyInc(e1->e1.getSal()*2));//line-1    }} How can the method, applyInc() of Employee class be redefined so that the functionality getting applied on Employee (doubling the salary) can be passed as an argument as in line-1? public int applyInc(Function<Employee, Integer> function) { return function.apply(this); }public int applyInc (Predicate<Employee> c) { return c.test(this); }public int applyInc (Consumer<Employee> c){ return c.accept(this); }Submit

Write a C program to store the information of employees in a company using structures. Each employee should have the following details:Employee code (integer)Employee name (string)Salary (float)Department number (integer)The program should allow the user to input the number of employees (n) and then input the details of each employee. i.Display the employee name with the maximum salary.ii. Display the average salary of all employees in the company.Test Case:3 // number of employees101  //Enter employee code:John Doe // Enter employee name:50000.00 // Enter salary:1  // Enter department number:102Jane Smith60000.001103Suresh Raina55000.002Output:Jane Smith55000.00  // avg of all employees salary

21. Write a Java program that creates a class hierarchy for employees of a company. The base class should be Employee, with subclasses Manager, Developer, and Programmer. Each subclass should have properties such as name, address, salary, and job title. Implement methods for calculating bonuses, generating performance reports, and managing projects

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.