What is the output of the following code? public class Mid_1 { public static void main(String[]...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
What is the output of the following code? public class Mid_1 { public static void main(String[] args) { Rectangle r1= new Rectangle(5, 6): Rectangle r2 = new Rectangle(); r1.setLen(6): r2.setWid(-10); r2.setLen(10); System.out.println("r1 len=" + r1.getLen()); System.out.println("r2 wid="+r2.getWid); System.out.println("r1 area= " + ri.area()); System.out.println("r2 area= " r2.area()) r2 = r1; System.out.println("r2 area= " + r2.area()); class Rectangle { private int len; private int wid; public Rectangle() { this.len = 5; this.wid = 5; } public Rectangle(int len, int wid){ this.len=len; this.wid = wid; public int getLen() { return len; } public int getWid() { return waid; } public public void setLen(int len) { if(len >0) this.len = len; public public void setWid(int wid) { if(wid >0) this.wid = wid; } public int area () { return len*wid; What is the output of the following code? public class Mid_1 { public static void main(String[] args) { Rectangle r1= new Rectangle(5, 6): Rectangle r2 = new Rectangle(); r1.setLen(6): r2.setWid(-10); r2.setLen(10); System.out.println("r1 len=" + r1.getLen()); System.out.println("r2 wid="+r2.getWid); System.out.println("r1 area= " + ri.area()); System.out.println("r2 area= " r2.area()) r2 = r1; System.out.println("r2 area= " + r2.area()); class Rectangle { private int len; private int wid; public Rectangle() { this.len = 5; this.wid = 5; } public Rectangle(int len, int wid){ this.len=len; this.wid = wid; public int getLen() { return len; } public int getWid() { return waid; } public public void setLen(int len) { if(len >0) this.len = len; public public void setWid(int wid) { if(wid >0) this.wid = wid; } public int area () { return len*wid;
Expert Answer:
Answer rating: 100% (QA)
Answer The provided code has several syntax errors and formatting issues Ill provid... View the full answer
Related Book For
Data Structures and Algorithms in Java
ISBN: 978-1118771334
6th edition
Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser
Posted Date:
Students also viewed these programming questions
-
What is the output of this code? Explain how did you made the file and provide a pic of the out put. import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class...
-
Lewis and Associates has been in the termite inspection and treatment business for five years. The following is a list of accounts for Lewis on June 30, 2017. It reflects the recurring transactions...
-
This chapter suggests that consumers judge service quality along five key dimensions: tangibles, reliability, responsiveness, assurance, and empathy. Which dimension is the most important to you when...
-
Pam and John are partners in PJ's partnership, having capital balances of $120,000 and $40,000, respectively, and share income in a ratio of 3:1. Gerry is to be admitted into the partnership with a...
-
Compare and contrast components to objects.
-
All trucks traveling on Interstate 40 between Albuquerque and Amarillo are required to stop at a weigh station. Trucks arrive at the weigh station at a rate of 200 per 8-hour day, and the station can...
-
What is the present value of $150 received at the beginning of each year for 16 years? The first payment is received today. Use a discount rate of 9%.
-
Joseph Berio is a loan officer with the First Bank of Tennessee. Red Brick, Incorporated, a major producer of masonry products, has applied for a short-term loan. Red Brick supplies building material...
-
Complete the Following Assisgnment Reflective Report (15%) As a student in the class Introduction to Tourism (TTP1100), you are required to write a reflective report. The report is to be based on an...
-
Demski Company pays its employees on the 1st and 15th of each month. It is March 31 and Demski is preparing financial statements for this quarter. Its employees have earned \(\$ 32,000\) since the 15...
-
On January 1, 2014, Shields, Inc., issued \(\$ 900,000\) of \(9 \%, 20\)-year bonds for \(\$ 989,067\), yielding a market (yield) rate of 8\%. Semiannual interest is payable on June 30 and December...
-
Assume Credins Bank made a 10 million, one-year discount loan at 7% interest, requiring a compensating balance equal to 10% of the face value of the loan. Determine the effective annual rate...
-
On January 1, 2014, Verrecchia Company issued \(\$ 450,000\) of 5-year, \(13 \%\) bonds for \(\$ 502,121\), yielding a market (yield) rate of \(10 \%\). Interest is payable semiannually on June 30...
-
On accepting the position of chief executive officer and chairman of Muse Inc., Dominic Howard changed the firms weekly payday from Monday afternoon to the following Friday afternoon. The firms...
-
The following information pertains to Mason Company for Year 2: Beginning inventory Units purchased 132 units e s38 390 units e $57 Ending inventory consisted of 50 units. Mason sold 472 units at...
-
A line l passes through the points with coordinates (0, 5) and (6, 7). a. Find the gradient of the line. b. Find an equation of the line in the form ax + by + c = 0.
-
Perform an experimental comparison of the relative speeds of the brute-force, KMP, and Boyer-Moore pattern-matching algorithms. Document the relative running times on large text documents that are...
-
Write a short Java method that takes an integer n and returns the sum of all the odd positive integers less than or equal to n.
-
Give an example input that requires merge-sort and heap-sort to take O(nlogn) time to sort, but insertion-sort runs in O(n) time. What if you reverse this list?
-
A lot of compensation information is available to employees today on the Web (e.g., www.salary.com), and much of it is inaccurate. How can an organization assure employees that they are fairly...
-
Flexible benefit plans are common today. Discuss ways in which employers can ensure that employees make good choices about the benefits and benefit levels that they choose within the benefits...
-
Payroll and benefits are commonly outsourced. Discuss which parts of PM, compensation, benefits, and payroll you would consider outsourcing; justifying your views.
Study smarter with the SolutionInn App