what is the difference between class and encapsulation in java?
Encapsulation is essentially "data hiding". A class is a construct that can be instantiated to create objects in memory. The class will use encapsulation (e.g. public and private methods) to hide attributes that you don't want to allow public access to. Finally an instance of the class will be created.