Hi,
Originally posted by Varalakshmi Ramanarayan:
This is a mock exam question on Java.Inquisition.
Given these two classes and that you want to promote better coupling between them. What changes are required to achieve good coupling ? Also given that the int variable main is to be used when initializing coupler�s variables.
My answer was 3.
because on line 3, coupler class is using the Instance variable of test class, which makes them tightly coupled.
Correct answer is 2.
Can soem one explain where I am going wrong?
My answer would be 3 also.
I'm not sure I understand entirely/correctly their option 2. Line#2 is definitely bad coupling.
Line #2 is so bad, it instantiate the class containing the main method and directly access its member.
I would consider this being an error and move on

Unless someone has a better idea.