179k views
6 votes
Please help!! Lots of points and Tommyinnit! 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

User Jitendra
by
3.4k points

2 Answers

9 votes

Answer:

1 and 11 only

Step-by-step explanation:

User Yechabbi
by
3.7k points
1 vote

Answer:

1 and 11 only

Step-by-step explanation:

Accessor methods reads from objects defined in a class, the getYearPublished() method can be deemed to be an accessor because it reads from the book object, the year in which a book was published. The returned value in the declared variable is int result which indicates that an integer value is expected to be read and returned by the getYearPublished() method. Hence, we can conclude that an integer is value is returned rather than a string. The getYearPublished() is expected to be public because class methods have no access to private members.

User DubyaDubyaDubyaDot
by
3.6k points