Flat 10% & upto 50% off + Free additional Courses. Hurry up!



There are three main features of OOPS:

  1. Encapsulation
  2. Inheritance
  3. Polymorphism


Wrapping of data and methods into a single unit is known as Encapsulation. It provides the security that keeps data and methods safe from unwanted changes. Class is the example of encapsulation which binds fields and members into a single unit.

To get encapsulation using

  • Declare the variables of a class as private.
  • Provides public getter and setter methods to change and sight the variables values.



public class Addition{

private int sum;

public void settotal(int a, int b){

sum = a + b;


public void gettotal()


System.out.println("Addition of two numbers:" +sum );


public static void main(String []args){

Addition add = new Addition ();

add.settotal(10, 20);





Addition of two numbers:30

Learn more about Cross-Platform Mobile Technology for Android and iOS using Java in this insightful blog now!

"0 Responses on Encapsulation"

Training in Cities

Bangalore, Hyderabad, Chennai, Delhi, Kolkata, UK, London, Chicago, San Francisco, Dallas, Washington, New York, Orlando, Boston

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.


Sales Offer

  • To avail this offer, enroll before 27th October 2016.
  • This offer cannot be combined with any other offer.
  • This offer is valid on selected courses only.
  • Please use coupon codes mentioned below to avail the offer
DW offer

Sign Up or Login to view the Free Encapsulation.