Question: //Find and correct all the errors in the following Java program. class Rectangle { private int height = 1; private int width = 1; public

//Find and correct all the errors in the following Java program. class Rectangle { private int height = 1; private int width = 1; public Rectangle(int height, int width) { height = this.height; width = this.width; } public void doubleHeight() { height += 2; } public void doubleWidth() { width *= 2; } public boolean isSquare() { return height = width; } public void draw() { for (int row = 0; row < width; row++) { for (int col = 0; col < height; col++) { System.out.println("X"); } System.out.println(); } } } class Driver { public static void main(String[] args) { Rectangle a = new Rectangle(3, 6); Rectangle b = new Rectangle(5, 3); a.doubleHeight; b.doubleWidth; if a.isSquare { System.out.println("First Rectangle is a square.") } else { System.out.println("First Rectangle is not a square.") } a.draw(); if b.isSquare { System.out.println("Second Rectangle is a square.") } else { System.out.println("Second Rectangle is not a square.") } b.draw(); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!