Which two are true?

Given:
1. class Book {
2. public String title;
3.
4. public void setTitle(String title) {
5. if (checkTitle(title)) this.title = title;
6. }
7. public String getTitle() {
8. return title;
9. }
10. private boolean checkTitle(String newTitle) {
11. // code that verifies proposed title change
12. }
13. }
Which two are true? (Choose two.)

Given:
1. class Book {
2. public String title;
3.
4. public void setTitle(String title) {
5. if (checkTitle(title)) this.title = title;
6. }
7. public String getTitle() {
8. return title;
9. }
10. private boolean checkTitle(String newTitle) {
11. // code that verifies proposed title change
12. }
13. }
Which two are true? (Choose two.)

A.
The title attribute is protected from direct modification by outside code.

B.
The Book class demonstrates encapsulation.

C.
The Book class does NOT provide information hiding.

D.
The Book class adheres to the JavaBeans naming conventions.

E.
The checkTitle method can be accessed from outside the Book class.



Leave a Reply 0

Your email address will not be published. Required fields are marked *