Online Courses
Free Tutorials  Go to Your University  Placement Preparation 
0 like 0 dislike
in JECRC University B.Tech(CSE-V Sem) Java Programming Lab by Goeduhub's Expert (5.8k points)
edited by

The length, width and area are of double type and colour is of string type. Create two objects of Rectangle and compare their area and colour. If the area and colour both are the same for the objects then display “Matching Rectangles”, otherwise display “Non-matching Rectangle”

Goeduhub's Top Online Courses @Udemy

For Indian Students- INR 360/- || For International Students- $9.99/-


Course Name



Tensorflow 2 & Keras:Deep Learning & Artificial Intelligence || Labeled as Highest Rated Course by Udemy

Apply Coupon


Complete Machine Learning & Data Science with Python| ML A-Z Apply Coupon


Complete Python Programming from scratch | Python Projects Apply Coupon
    More Courses

1 Answer

0 like 0 dislike
by Goeduhub's Expert (5.8k points)
edited by
Best answer

Program Code


import java.util.*;

class Rect


  double width,length,area;

  String color;

  Scanner sc=new Scanner(;



   System.out.print("Enter the length: ");


   System.out.print("Enter the width: ");


   System.out.print("Enter the color: ");;


    System.out.println("Area of Rectangle: "+area);



class Demo


   public static void main(String arg[])


   System.out.println("First Rectangle: ");

   Rect r1=new Rect();

   System.out.println("Second Rectangle: ");

   Rect r2=new Rect();

   if(r1.area==r2.area && r1.color.equals(r2.color))

          System.out.println("Matching Rectangle ");


          System.out.println("Non Matching Rectangle ");




First Rectangle:

Enter the length: 10.22

Enter the width: 12.22

Enter the color: blue

Area of Rectangle: 124.88840000000002

Second Rectangle:

Enter the length: 12.22

Enter the width: 10.22

Enter the color: blue

Area of Rectangle: 124.88840000000002

Matching Rectangle

For more JU V Sem Java Lab Experiments Click here

3.3k questions

7.1k answers


4.6k users

Related questions


About Us | Contact Us || Terms & Conditions | Privacy Policy || Youtube Channel || Telegram Channel © Social::   |  |