Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5 Consider the following Java classes, Program.java and Developer.java. Write down the output of the following when you run the Program class. Marks 5 public

5 Consider the following Java classes, Program.java and Developer.java. Write down the output of the following when you run the Program class.
Marks 5
public class Program {
public static void main(String[] args){
Developer dev1= new Developer ("Alice",5000);
Developer dev2= new Developer();
System.out.println("Salary of "+ dev1.getName()+
" is: "+ dev1.getSalary ());
System,out.printin("Salary of "+ dev2. getNam()+
" is: "+ dev2.getSalary());
dev2.increaseSalary (1000);
System.out.println(dev1=e dev2);
dev1= dev2;
System.out.println(dev1== dev2);
dev1.increaseSalary (200);
System.out.println("Salary of "+ dev1.getName()+
}
" is: "+ dev1.getSalary());
}
public class Developer {
private String name;
private double salary;
public Developer(String name, double salary){ this. name = name;
}
this.salary = salary;
public Developer(){
this. name = "Bob";
}
this.salary =6000;
public String getName(){
return name;
}
public double getSalary(){ return salary;
}
public void increaseSalary(double increment) & this.salary + increment;
}
}.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions