226k views
0 votes
Hey can someone please help me solve this question I’m failing can y’all help me pleaseee

Assume that the following code exists inside a method of the class MyClass, and that this code compiles without errors:
int result = book.getYearPublished();


where book is an object of the Book class.


Which of the following is true about the getYearPublished method?


I. It is an accessor method.

II. It is a public method in the Book class.

III. It returns a String.


Answer choices.

I only

II only

III only

I and II only

I and III only

2 Answers

4 votes

Answer:

Some body reported your question

Step-by-step explanation:

User Zawadi
by
5.8k points
1 vote

Answer:

I and II only

Step-by-step explanation:

It is an accessor method ; the getYearPublished() is meant to read data from book objects defined in the book class, the getYearPublished() will likely read the year in which the book was published, hence it is an accessor method as accessors read from data members.

Since, getYearPublished() can read from object of the book class, then it would be a public method because class objects has no authorization to private data and hence will throw an error.

String are letters or words, however, the returned result indicates an integer, hence, an integer rather than a string is returned.

User SeriousDron
by
6.4k points