Assume that the following code exists inside a method of 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 not true about the getYearPublished method?(1 point)I. It is a mutator method.II. It is a public method in the Book class.III. It returns a String.1) I only2) II only3) III only4) I and II only5) I and III only

Respuesta :

Answer:

Option (5)

Explanation:

Since, it is returning a value which is stored in a variable result which is of int type, that is why, III is wrong as it cannot return a string. Moreover, A mutator method is one which changes the value of a private member of a class and they don't return anything of any type. But the statement is returning a value of int type so, it cannot be a mutator method. So, I and III are not true. Since, object of book class is able to access that method , it must be a public method otherwise error would have displayed as objects of class has no access to their private members and can invoke public member functions only. So, II is true.

ACCESS MORE