Program with Multiple Classes in Java / Do addition using multiple classes in Java

Program with Multiple Classes in Java 






  1. class Test
  2. {
  3. int a,b,c;
  4. void getdata(int x,int y)
  5. {
  6. a=x;
  7. b=y;
  8. }
  9. void add()
  10. {
  11. c=a+b;
  12. System.out.println("Addition is "+c);
  13. }
  14. }
  15. class Imp
  16. {
  17. public static void main(String args[])
  18.  {
  19. Test t=new Test();
  20. t.getdata(100,200);
  21. t.add();
  22. }
  23. }



Output:


Comments

Post a Comment

If you have any query, please let us know