Answer to Question #239310 in Java | JSP | JSF for Tarurendra Kushwah

Question #239310

Write a program to implement encapsulation.


1
Expert's answer
2021-09-20T16:43:39-0400
public class Main{  
public static void main(String[] args){   
    Employee s=new Employee();  
    s.setName("abc");   
    System.out.println(s.getName());  
    }  
}  


class Employee{   
    private String emp_name;   
    public String getName(){  
        return emp_name;  
    }  
  
    public void setName(String emp_name){  
        this.emp_name=emp_name;  
    }  
}  

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS