Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

First exam practice 3b

+13 votes
Can anyone answer the 3b question (about public interface) Or anyone have definition of public interface of an object? Thanks
asked Sep 22, 2015 in Fall 15-16 by An Nguyen Dang (100 points)

2 Answers

+6 votes
 
Best answer

The public interface of a class includes the methods and data that it exposes publicly (i.e., that other classes can use).

(Java "Interfaces" provide a way to formally specify "interfaces" that other classes may use... but whether or not a class implements an official "Interface", it still has an interface nonetheless -- that is, all the the methods that it makes available for other classes' code to use).

So, the answer in this case is:  the set of two methods, getName() and getOwner(), together form the public interface for the Horse class.

answered Sep 22, 2015 by Forrest Stonedahl (100 points)
selected Sep 22, 2015 by An Nguyen Dang
–1 vote
String I think, because it is also implementing the String Class as will at owned Object
answered Sep 22, 2015 by Kelsey Self (100 points)
No, the Horse class contains a reference to the String class, but that does not involve "implementing" an interface at all.
...