what is loose coupling and tight coupling in oop ( java )
java, oop
Solution
Inheritance does not always give tight coupling - since the class you are inheriting provides a defined way to do so through which methods it declares as being private, protected and public.
A good example of this is many of the abstract classes provided by various APIs which implement some of the boiler plate functionality of an interface for you and allow you to focus on your own requirements.
Basic examples include the "adaptor" classes in swing which provide "no-op" implementations of all of the methods in the interface. More advanced examples actually provide standard implementations of some of the requirement of the interface.
Exactly what is tight coupling really is very much a judgement call with many things obviously being tightly coupled, others being obviously loosely coupled - and then a large grey area in between.
Problem
i have some confusion regarding loose coupling and tight coupling in java.as i know loose coupled means least information about each other and tight coupled means dependency.as we know loose coupling can achieve through interface implementation and inheritance make tight couple. for example: 1) A (interface)<--------------------- B (class) 2) C ( class ) <--------------------- D (class) suppose these four classes is part of my entire application, making change in B or D do not make any impact on application(for running point of view). removing any method or variables from A or C required so many change in application. all right score is 2-2, but adding new method in C or A is different. if i added new method in C do not impact on application but in adding in A , at least i have to override this method in B and all the classes that implement interface A. so how it's loose coupling at least in this scenario. my doubt is, is inheritance give always tight coupling.i learned Inheritance is one of powerful tool of OOP.for designing if a class follow the "is a relationship" then use inheritance. loose coupling means less information about each other. A and C both don't know in future which class is going to implements or extends,but after adding B and D now B is not dependent on A because it's all method's are abstract, but D can also override the inheriting feature.