Assignment: Module 03- Part 01
![]() |
Assignment: Module 03- Part 01 |
08. Write a class MethodReturn which contains instance method displaySalary(double salary, double hra) to calculate the salary of Vishal.
Input parameters :
displaySalary(20000,2000)
Output:
Vishal salary is 22000.0
class MethodReturn {
public void displaySalary(double salary, double hra) {
double vishalSalary = salary + hra;
System.out.println("Vishal salary is " + vishalSalary);
}
}
public class Main {
public static void main(String[] args) {
MethodReturn obj = new MethodReturn();
obj.displaySalary(20000, 2000); //output: Vishal salary is 22000.0
}
}
This is printed to the console by the 'System.out.println' statement in the 'displaySalary' method. The output is the salary of Vishal calculated by adding his salary and hra.