A Programming I 10 marks Rewrite the provided Box class so t
Solution
program
                         interface Comparable
 {
 public class Box
 {
    public int data1;
    public String name1;
 public Box1(String n1, int d1)
 {
      name1=n1;
      data1=d1;
    }
 }public Box2(String n2, int d2)
 {
      name2=n;
      data2=d;
    }
 class Box implements Comparable
 {
      if ( name1.compareTo(name2) > 0 )
          System.out.println(\"First string is greater than second.\");
       else if ( name1.compareTo(name2) < 0 )
          System.out.println(\"First string is smaller than second.\");
       else
          System.out.println(\"Both strings are equal.\");
 }
 if ( data1.compareTo(data2) > 0 )
          System.out.println(\"First string is greater than second.\");
       else if ( data1.compareTo(data2) < 0 )
          System.out.println(\"First string is smaller than second.\");
       else
          System.out.println(\"Both strings are equal.\");
 }
 class Comp
 {
 public static void main(String args[])
     {
 Comparable obj=new Box();
 obj.box1(\"abcd\",\"xyz\");
 obj.box2(\"efgh\",\"pqr\");
      }
 }

