This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
p is a reference to a Person object p.getCar() is a reference to a Car object p.getCar().getName() is a reference to a String object
In theory, so long as each method returns a reference to an object, you can string any number of "."s together.
In practice, it would be bad coding to put too many - certainly not more than what you've got here. For example, the following clearly does the same :
However, the advantage with splitting the code like this is it enables debugging and maintenance. You can log the value of myCar to ensure it's what you expected it to be, etc.
There is a fairly well known principle called the Law of Demeter which spells out the best practices for using this kind of multi-level access. In short: don't. If you find yourself using multiple dots in an expression, it's a clue that the code you're writing belongs in some other class.