Menu
Question Index
...

What will be the output of the following program?

public class SalaryIs {
    public static void main(String[] args) {
        Salary s = new Salary("Kiran", "Anantapur, AP", 3, 25000);
        System.out.println("Check the mail:- ");
        s.mailCheck();
    }
}
class Salary extends Employee {
    private double salary;
    public Salary(String name, String address, int number, double salary) {
        super(name, address, number);
        setSalary(salary);
    }
    public void mailCheck() {
        System.out.println("Check your mail Mr. " + getName() + " your salary is deposited " + salary);
    }
    public double getSalary() {
        return salary;
    }
    public void setSalary(double newSalary) {
        if (newSalary >= 0.0)
            salary = newSalary;
    }
    public double computePay() {
        System.out.println("Salary paid to " + getName());
        return salary / 52;
    }
}

class Employee {
    private final String name;
    public Employee(String name, String address, int number) {
        this.name = name;
    }
    public String getName() {
        return name;
    }
}


Check the mail:-
Check your mail Mr. Kiran your salary is deposited 25000.0
Check the mail:-
Check your mail Mr. Kiran your salary is deposited 25000.0
Salary paid to Kiran
Check the mail:-
Salary paid to Kiran
Check your mail Mr. Kiran your salary is deposited 25000.0
Check the mail:-
Check your mail Mr. Kiran your salary is deposited 480.769
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Unknown

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App