Multiple Choice
For the questions below, consider a class called ChessPiece. This class has two instance data, String type and int player. The variable type will store "King", "Queen", "Bishop", etc and the int player will store 0 or 1 depending on whose piece it is. We wish to implement Comparable for the ChessPiece class. Assume that, the current ChessPiece is compared to a ChessPiece passed as a parameter. Pieces are ordered as follows: "Pawn" is a lesser piece to a "Knight" and a "Bishop", "Knight" and "Bishop" are equivalent for this example, both are lesser pieces to a "Rook" which is a lesser piece to a "Queen" which is a lesser piece to a "King."
-Which of the following pieces of logic could be used in the method that implements Comparable? Assume that the method is passed Object a, which is really a ChessPiece. Also assume that ChessPiece has a method called returnType which returns the type of the given piece. Only one of these answers has correct logic.
A) if (this.type < a.returnType( ) ) return -1;
B) if (this.type = = a.returnType( ) ) return 0;
C) if (this.type.equals(a.returnType( ) ) return 0;
D) if (a.returnType( ) .equals("King") ) return -1;
E) if (a.returnType( ) .equals("Pawn") ) return 1;
Correct Answer:

Verified
Correct Answer:
Verified
Q2: An object that refers to part of
Q26: Why should the add( ), subtract( ),
Q27: Draw the JFrame as you think it
Q28: Provide a reason why an instance data
Q29: Provide code to generate the following JFrame.
Q30: The size and shape of a GUI
Q31: An example of an aggregation relationship is<br>A)
Q37: Of the various phases in software development,
Q47: Interface classes cannot be extended but classes
Q47: Defining formal parameters requires including each parameter's