fork download
  1. public class L1employee
  2. {
  3. public static void main(String args[])
  4. {
  5. //declaring and creating an instance of class Person
  6. Person p1 = new Person();
  7.  
  8. //This displays the attribute name of p1
  9. System.out.println("Emloyee name is " + p1.name);
  10. System.out.println("");
  11.  
  12. System.out.println("The details about this person are: ");
  13. p1.display();
  14. }
  15. }
  16. //This is the class Person
  17. class Person
  18. {
  19. //attributes of class Person
  20. String name = "John Murphy";
  21. String phone = "003531234567";
  22. String email = "johnmurphy@yahoo.com";
  23.  
  24. Public void display()
  25. {
  26.  
  27. //method to display details about the person
  28. System.out.println(" ");
  29. System.out.println("Name " + name);
  30. System.out.println(" ");
  31. System.out.println("Phone " + phone);
  32. System.out.println(" ");
  33. System.out.println("E-mail" + email);
  34. System.out.println(" ");
  35. }
  36. }
  37.  
Runtime error #stdin #stdout 0.02s 4980KB
stdin
Standard input is empty
stdout
Standard output is empty