What is the advantage of the code on the top compared to the…

What is the advantage of the code on the top compared to the one on the bottom. (Note: BalanceException is a checked exception)   int withdraw(int amount) {   if (amount > balance)       return -1;   else {       balance -= amount;        return 0;   } }   void withdraw(int amount) throws BalanceException{  if (amount > balance){        throw new BalanceException();   }   balance -= amount; }  

Does this code compile? Does it produce a compilation warnin…

Does this code compile? Does it produce a compilation warning? Does it produce a runtime error? Explain the behavior and the reason behind it.   public static void func(Number arr[]){       arr[0] = 5.0;      } public static void main(String [] args) {     Integer arr[] = new Integer[100];     func(arr); }

Following Type Eraser, how does the code below look like?   …

Following Type Eraser, how does the code below look like?                  Before: class GeometricObject {  public double getArea() {return 1.0;}  } public static boolean  equalArea(E object1, E object2)  {     return object1.getArea() ==  object2.getArea(); }                  After: ?

Given the class hierarchy below. Could the symmetry of equal…

Given the class hierarchy below. Could the symmetry of equals() be violated? If yes, provide client code that demonstrates that.   class A {   int x;   public A(int x) {this.x = x;}   public boolean equals(Object o) {        if (!(o instanceof A)) return false;        A a = (A)o;        return this.x == a.x;   }        } class B extends A {   int y;   public B(int x, int y) {super(x); this.y = y;} }  

Barry’s Sport Shop calls Champs Tee Shirt Company to order 2…

Barry’s Sport Shop calls Champs Tee Shirt Company to order 200 designer tee shirts at $2 per shirt. The next day, Barry decides he can easily sell 100 more. Before the order is filled, he calls to change the order to 300 tee shirts. Champs sends 200. Can Barry force Champs to send the additional 100?