java - Explain how the concepts of encapsulation and delegation -


so, i'm trying find how related each other, can't seem find anything.

a), relate each other b), how differ each other

encapsulation core principal, refers bundling of data methods operate on data. basically, logic , data go together. if have class, properties , logic – encapsulated. helps separation of concerns , reduces surface areas – supports immutability – since object can control data.

delegation when @ runtime can invoke different object complete task dynamically. useful oo pattern.


Comments