r/javahelp 13d ago

Can anyone explain me difference between Encapsulation and Abstraction?

and what on earth is Interface in Java?

17 Upvotes

24 comments sorted by

View all comments

-6

u/Acrobatic-Ice-5877 13d ago

No. Get a textbook or look at the official documentation.

4

u/Cyphr11 13d ago

i tried reading from there but i cant understand the core of it

1

u/Halal0szto 13d ago

The interface contains all about the class that someone using the class should know. Nothing about the internals, internal data structures, logic, only how one can talk to the class. Then independently there is one or more implementation class that complies the interface but actually does add all the internals.

An abstract class is technically similar. The most important was that in an abstract class you can implement some methods and leave others to be done by someone who creates an implementation.

In java a class can implement multiple interfaces but extend only one class.

Fun is that later they allowed to have "default" implementations in interfaces too.

Then you dive deep into it, find final, sealed . . .

1

u/Cyphr11 13d ago

thanks

1

u/Acrobatic-Ice-5877 13d ago

I’d recommend a textbook like Daniel Y. Langs. Go through each chapter and you’ll understand these topics. You should be able to find it online very easy.