Using Jcreator, open, compile, and run java and observe its runtime. Write your observation regarding how encapsulation works for the program and the data it processed. Limit your paper to a single...


Using Jcreator, open, compile, and run java and observe its runtime. Write your observation regarding how encapsulation works for the program and the data it processed. Limit your paper to a single paragraph with at least 50 words or five (5) sentences.



Source code:


public class EncapTest {
   private String name;
   private String idNum;
   private int age;


   public int getAge() {
      return age;
   }


   public String getName() {
      return name;
   }


   public String getIdNum() {
      return idNum;
   }


   public void setAge( int newAge) {
      age = newAge;
   }


   public void setName(String newName) {
      name = newName;
   }


   public void setIdNum( String newId) {
      idNum = newId;
   }
}


public class RunEncap {


   public static void main(String args[]) {
      EncapTest encap = new EncapTest();
      encap.setName("James");
      encap.setAge(20);
      encap.setIdNum("12343ms");


      System.out.print("Name : " + encap.getName() + " Age : " + encap.getAge());
   }
}





Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here