Given the following java class on the left, what is the output of running the main...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given the following java class on the left, what is the output of running the main method on the right? Show your work and draw objects in RAM for partial credit. public class Player ( private String name: private int score; private static int best = 0; public player (String name) { this.setName (name); last=0; } public player (Player p) { this (p.name); } public void setName (String name) { this.name name: } public void setScore (ints) { score = 5; if (best <s) bests; public static int getBestScore () ( return best; public String toString() { return name":"+ score; // end class player public class Testing ( public static void main(String] args). { Player pl = new Player("A"); Player p2 = new Player ("B"); Player p3 new Player (p2); pl.setScore (10): p2.setScore (20); p3.setScore (15); System.out.println(pl); System.out.println (p3); System.out.println("Best = " + Player.getBestScore()); p3 p1; pl.setScore (50): System.out.println (p3); Given the following java class on the left, what is the output of running the main method on the right? Show your work and draw objects in RAM for partial credit. public class Player ( private String name: private int score; private static int best = 0; public player (String name) { this.setName (name); last=0; } public player (Player p) { this (p.name); } public void setName (String name) { this.name name: } public void setScore (ints) { score = 5; if (best <s) bests; public static int getBestScore () ( return best; public String toString() { return name":"+ score; // end class player public class Testing ( public static void main(String] args). { Player pl = new Player("A"); Player p2 = new Player ("B"); Player p3 new Player (p2); pl.setScore (10): p2.setScore (20); p3.setScore (15); System.out.println(pl); System.out.println (p3); System.out.println("Best = " + Player.getBestScore()); p3 p1; pl.setScore (50): System.out.println (p3);
Expert Answer:
Answer rating: 100% (QA)
The Player class has three private instance variables name score and best with a static variable lasto for tracking the best score among all Player in... View the full answer
Related Book For
An Introduction to Geotechnical Engineering
ISBN: 978-0132496346
2nd edition
Authors: Robert D. Holtz, William D. Kovacs, Thomas C. Sheahan
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
An appropriate structure for large-scale distributed systems is as multiple, independently administered, firewall-protected, domains. Examples are a national health service, a national police service...
-
The separation of operational responsibility from record keeping is meant to prevent different types of misstatements than the separation of the custody of assets from accounting. Explain the...
-
Suppose we would like the landing speed of block 2 to be increased to 1.50 m/s. (a) Should the coefficient of kinetic friction between block 1 and the tabletop be increased or decreased? (b) Find the...
-
The following information is from the work sheet for Hascal Company as of December 31, 2023. Using this information, determine the amount for Sam Hascal, Capital that should be reported on the...
-
Air flows in a 15-cm-diameter horizontal pipe. At section 1, \(p=600 \mathrm{kPa}, T=70{ }^{\circ} \mathrm{C}\), and \(V=35 \mathrm{~m} / \mathrm{s}\). At section 2: \(T=42^{\circ} \mathrm{C}\) and...
-
You are considering opening a bagel restaurant aimed primarily at the breakfast trade. Youll sell bagels, coffee, and other items in relatively fixed proportions to one another. For each bagel sold,...
-
In the last column for NYTD,figure out how NYT'sDNA elements will impact their performance. What DNA elements should NYTD keep, what should it jettison, and what should it change? A element...
-
1. Take a position either for or against the following statement: To prepare for disasters, you should stockpile inventory, other critical supplies, and raw materials. 2. Think of Heinzs (H. J. Heinz...
-
Gabby is 36 years old and files as single. During 2021, Gabby has the following items of Income and possible deductions: Income Items: Salary Interest income from Banks Municipal bond interest...
-
In a payroll data set, you would like to check for employees where the ratio of the Net Pay to Gross Pay is greater than 70% indicating low statutory deductions and red-flags on possible ghost...
-
Enhancing Financial Reporting Quality through Corporate Ethics Commitment As you read the attached paper, please reflect on these with respect to the experience you have gained in preparing the...
-
Your firm is considering a new market project. The project will require an equipment purchase of $250,000. The equipment also requires a delivery fee of $25,000. The project will generate revenue in...
-
How does the Marxist view of economic forces differ from the transparent free-market view? Provide in-text citations and references to support your response.
-
What are the advantages and disadvantages of autocratic leadership? Cite an example from your own experience that describes autocratic leadership. Your response should be at least 200 words in...
-
Compile a list of the differences between Roman Catholicism and Eastern Orthodoxy.
-
Splitting hairs, if you shine a beam of colored light to a friend above in a high tower, will the color of light your friend receives be the same color you send? Explain.
-
Two consolidated-drained triaxial tests were performed on specimens of the same clay, with the following results at failure: Test 1: '1 = 73.4 psi, '3 = 26.6 psi Test 2: '1 = 48.0 psi, '3 = 12.0 psi...
-
The natural water content of a borrow material is known to be 8%. Assuming 5500 g of wet soil is used for laboratory compaction test points, compute how much water is to be added to other 5500 g...
-
Soil borings made at a site near Chicago indicate that the top 6 m is a loose sand and miscellaneous fill, with the groundwater table at 3 m below the ground surface. Below this is a fairly soft...
-
Which of the following are boiler mountings ? (a) Economiser (b) Fusible plug (c) Super heater (d) Injector
-
Which out of the following boiler is capable of generating superheated steam without additional accessories ? (a) Cochran (b) Lancashire (c) Locomotive (d) Cornish
-
The economiser of the boiler plant is used mainly to (a) increase steam capacity (b) reduce fuel consumption (c) increase steam pressure (d) increase life of the boiler
Study smarter with the SolutionInn App