Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is the problem and key. how do you know the characteristics of the set when you print them initially? Klingonox sl 10,15 S2 90,56

this is the problem and key. how do you know the characteristics of the set when you print them initially? image text in transcribed
image text in transcribed
Klingonox sl 10,15 S2 90,56 Furball Example #2 - Class Type as Parameters 1. public class ParametersDemo 2. 3. public static void main(String[] args) 4. 5. DemoSpecies sl-new DemoSpecies(), 12 new DemoSpecies: 6. sl.set("Klingon Ox", 10, 15); 7. s2.set("Fur Ball", 90, 56): 8. System.out.println("Value of s2 before call to method:"); 9. s2.writeOutput: 10. sl.makeEqual(s2). 11. System.out.println("Value of s2 after call to method:"); 12. s2.writeOutput: 13. int Population - 42; 14. System.out.println("Value of Population before call to method: "+ Population); 15. sl.try To Make Equal(aPopulation). 16. System.out.println("Value of Population after call to method: Population); 17.) 18.) value os 2 before call to mehed 19. public class DemoSpecies 20. 21. private String name: 22. private int population; 23. private double growthRate; 24. public void makeEqual(DemoSpecies otherObject) 25. 26. otherObject.name = this.name; 27. otherObject.population this population; 28. otherObject growthRate this growthRate; 29.) 30. public void try To Make Equalint intVariable) 31. 32. intVariable - this.population; 33.) 34. public void writeOutput 35. 36. System.out.println("Name="+ name); 37. System.out.println("Population - " + population): 1 Lecture Note 3 38. System.out.println("Growth rate =" + growthRate + "%"); 39.) 40. public void set(String newName, int newPopulation, double newGrowthRate) 41. { 42. name = newName; 43. if (newPopulation >=0) 44. population = newPopulation; 45. else 46. { 47. System.out.println("ERROR: using a negative population."); 48. System.exit(0); 49. } 50. growthRate = newGrowth Rate; 51. } 52. } Output of Example 2 Value of s2 before call to method: Name = Fur Ball Population = 90 Growth Rate = 56.0% Value of s2 after call to method: Name = Klingon Ox Population = 10 Growth Rate = 15.0% Value of aPopulation before call to method: 42 Value of apopulation after call to method: 42

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

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

Question May a taxpayer roll over money from an IRA to an HSA?

Answered: 1 week ago

Question

Question What is the doughnut hole in HSA coverage?

Answered: 1 week ago