Advertisement
Guest User

Untitled

a guest
Sep 1st, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. import java.io.*;
  2. class Person
  3. {
  4.  
  5. String name;
  6. int age;
  7. float salary;
  8.  
  9.  
  10. Person(String n,int a,float s)
  11.  
  12. {
  13.  
  14. name=n;
  15. age=a;
  16. salary=s;
  17.  
  18.  
  19.  
  20.  
  21.  
  22. }
  23.  
  24. void DisplayMethod()
  25. {
  26. System.out.println("Your name is: "+name+"\nYour age is: "+age+"\nYour salary is: "+salary);
  27. }
  28.  
  29. }
  30.  
  31. class Ex2
  32. {
  33. public static void main(String args[])
  34. {
  35. Person obj=new Person("Ali",23,3500);
  36. obj.DisplayMethod();
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement