A team of programmers is reviewing a proposed API for a new utility class. After some discussion, they realize that they can reduce the number of methods in the API without losing any functionality. If they implement the new design, which two OO principles will they be promoting?
Given:
21. class Money {
22. private String country = Canada;
23. public String getC() { return country; }
24. }
25. class Yen extends Money {
26. public String getC() { return super.country; }
27. }
28. public class Euro extends Money {
29. public String getC(int x) { return super.getC(); }
30. public static void main(String[] args) {
31. System.out.print(new Yen().getC() + + new Euro().getC());
32. }
33. }
What is the result?
Assuming that the serializeBanana() and the deserializeBanana() methods will correctly use Java
serialization and given:
13. import java.io.*;
14. class Food implements Serializable {int good = 3;}
15. class Fruit extends Food {int juice = 5;}
16. public class Banana extends Fruit {
17. int yellow = 4;
18. public static void main(String [] args) {
19. Banana b = new Banana(); Banana b2 = new Banana();
20. b.serializeBanana(b); // assume correct serialization
21. b2 = b.deserializeBanana(); // assume correct
22. System.out.println(restore +b2.yellow+ b2.juice+b2.good);
24. }
25. // more Banana methods go here
50. }
What is the result?
Given a valid DateFormat object named df, and
16. Date d = new Date(0L);
17. String ds = December 15, 2004;
18. //insert code here
What updates d's value with the date represented by ds?
Given:
11. double input = 314159.26;
12. NumberFormat nf = NumberFormat.getInstance(Locale.ITALIAN);
13. String b;
14. //insert code here
Which code, inserted at line 14, sets the value of b to 314.159,26?