Encapsulation:

binding of datatypes and method inside in one class-->is called Encapsulation.

Case study:

class governmentExam{
    int candidateid=123,;
	String candidatename="sam";
		
    void candidatedetail(){
	    System.out.println(candidateid+" "+candidatename);
    }
			
	void marks(int IT,int Maths){
      System.out.println("Marks of IT: "+IT+"Marks of Maths: "+Maths);
    }
}		  
          

class hack{
    public static void main(String args[]){
        governmentExam g=new governmentExam();
		g.marks(90,90);
  }
}	  
          

output:
 123 sam
Marks of IT: 50  Marks of Maths: 60		  
          

Case study 2:

   class governmentExam{
        int candidateid=123,;
		String candidatename="sam";
		
		void candidatedetail(){
		    System.out.println(candidateid+" "+candidatename);
			}
			
		void marks(int IT,int Maths){
		      System.out.println("Marks of IT: "+IT+"Marks of Maths: "+Maths);
			  }
	}	  
          

 class hack{
       public static void main(String args[]){
	        governmentExam g=new governmentExam();
			
			g.candidateid=456;
			g.candidatename="max";
			g.candidatedetail();
			g.marks(90,90);
			  }
	}	  
          

	  output:
         456 max
		 Marks of IT: 50  Marks of Maths: 60
          

Conclude: Our application hacks write now

Solution:

class governmentExam{
    private int candidateid=123,;
	private String candidatename="sam";
	
    void candidatedetail(){
	    System.out.println(candidateid+" "+candidatename);
	}
			
	void marks(int IT,int Maths){
	    System.out.println("Marks of IT: "+IT+"Marks of Maths: "+Maths);
	}
}
          

class hack{
    public static void main(String args[]){
        governmentExam g=new governmentExam();
		g.candidateid=456;//error throw
		g.candidatename="max";// error throw
		g.candidatedetail();
		g.marks(90,90);
	  }
}
          

output:
456 max
Marks of IT: 50  Marks of Maths: 60
          

Address

Plot number-56/1
Near Gurudwara
LandMark :
Opposite A.N.D college
Govindpuri Metro station
New Delhi
Mobile number:
8826034620