rect answerA class Manager wants to implement an interface Salary. Which of the following is the correct way of implementing it?
Question
A class Manager wants to implement an interface Salary. Which of the following is the correct way of implementing it?
Solution
The correct way to implement an interface in Java would be:
public interface Salary {
// methods
}
public class Manager implements Salary {
// methods
}
Here are the steps:
-
Define the interface using the
interface
keyword. In this case, the interface is namedSalary
. Inside the interface, you can define methods that the class implementing the interface will have to override. -
Define the class using the
class
keyword. In this case, the class is namedManager
. -
Use the
implements
keyword in the class definition to specify that the class is implementing theSalary
interface. -
Inside the
Manager
class, override the methods defined in theSalary
interface. These methods should have the exact same method signatures as in the interface.
Similar Questions
Define a class Employee. Display the personal salary details of three employeesusing single inheritance
Which of the following is a resource made available to employees, in addition to salary?Question 10Select one:a.wagesb.amenitiesc.remunerationd.compensation
Multiple Choice Question_____ are the financial rewards based on the number of hours an employee works.Multiple choice question.SalariesBenefitsWagesCommission
In Java programming, the keyword used to implement an interface in a class is:Question 4Answera.usesb.extendsc.requiresd.implements
Question 301 ptsThe fixed amount of salary a salesperson earns is referred to as his or her base salary.Group of answer choicestruefalse PreviousNext
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.