Himanshu Mall wrote:@Abhimaran
Pardon me if i am drifting away from Exam's objective.
But as soon as we start speaking class instead of type, we get hooked to that particular class. For loose coupling in pure sense, two objects should talk to each other over an abstraction, i.e. interface.
Please correct me if i am wrong.
Himanshu, I think you are right, because when I was doing some exercises from K&B
Java 5 (chapter 2 - exercise 5) I found something that matches with what you said.
There is a question that calls for assertions that better points a loosely coupling situation.
There is an assertion that I thought that it was valid: "All classes attributes are private".
So, checking the answers that assertion was not valid. So, I can infer that only making instance variables private do not make a loosely coupling.
Considering all that, I think you are right when saying that for loose coupling we need to use abstraction (i.e. interface)