Answered step by step
Verified Expert Solution
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) { 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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started