Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

What is the output of the following code? public class Mid_1 { public static void main(String[] args) {

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;

Step by Step Solution

3.36 Rating (159 Votes )

There are 3 Steps involved in it

Step: 1

Answer The provided code has several syntax errors and formatting issues Ill provid... 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

Data Structures and Algorithms in Java

Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser

6th edition

1118771334, 1118771338, 978-1118771334

More Books

Students also viewed these Programming questions