Write the following code A class named Arithmetic with a method named add that takes integers as parameters and returns an integer denoting their sum. A class named Adder that inherits from a superclass named Arithmetic & overwrite add method. Input Format: calling the add method on an Adder object and passing it integer parameters
please solve (Java problem using class inheritence and encapsulation)
- Write the following code
- A class named Arithmetic with a method named add that takes integers as parameters and returns an integer denoting their sum.
- A class named Adder that inherits from a superclass named Arithmetic & overwrite add method.
Input Format: calling the add method on an Adder object and passing it integer parameters.
2.Create a class called Employee whose objects are records for an employee. This class will be a derived class of the class Person. An employee record has an employee's name (which is a private property and inherited from the class Person), an annual salary represented as a single value of type double & private property, a year the employee started work as a single value of type int and a national insurance number, which is a value of type String & private property of the Employee class. Write another class containing a main method to fully test your class definition.
3.Create a class called Bank which contains bank’s name, address, number of branch of that bank. Usually a bank has different scheme like savings account, fixed deposit, DPS. All scheme has different interest rate like 4%, 6%, and 4.5%. Write class for each scheme which inherit bank class & must implement a method which calculate amount including interest rate based on any amount.
4.Create an class named Pet which contains 3 method named getName(), setName() & play(). Create a class named Cat that inherit Pet class & contains a method named eat(). Create another class named Fish that also inherit Pet class & override play() ethod. Write a test application that demonstrates each class’s capabilities.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images