2.Given: 20. public class CreditCard { 21. 22. private String cardID; 23. private Integer limit; 24. public String ownerName; 25. 26. public void setCardInformation(String cardID, 27. String ownerName, 28. Integer limit) { 29. this.cardID = cardID; 30. this.ownerName = ownerName; 31. this.limit = limit; 32. } 33. } Which statement is true?
A.The class is fully encapsulated.
B.The code demonstrates polymorphism.
C.The ownerName variable breaks encapsulation.
D.The cardID and limit variables break polymorphism.
E.The setCardInformation method breaks encapsulation.
Correct:C
3.Given: 1. class Super { 2. private int a; 3. protected Super(int a) { this.a = a; } 4. } ... 11. class Sub extends Super { 12. public Sub(int a) { super(a); } 13. public Sub() { this.a = 5; } 14. } Which two, independently, will allow Sub to compile? (Choose two.)
A.Change line 2 to: public int a;
B.Change line 2 to: protected int a;
C.Change line 13 to: public Sub() { this(5); }
D.Change line 13 to: public Sub() { super(5); }
E.Change line 13 to: public Sub() { super(a); }
Correct:C D
4.Which two statements are true? (Choose two.)
A.An encapsulated, public class promotes re-use.
B.Classes that share the same interface are always tightly encapsulated.
C.An encapsulated class allows subclasses to overload methods, but does NOT allow overriding methods.
D.An encapsulated class allows a programmer to change an implementation without affecting outside code.
Correct:A D
没有评论:
发表评论