Findryan

Untitled

Nov 17th, 2016
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. class MyClass
  2. {
  3. int height;
  4. MyClass()
  5. {
  6. System.out.println("bricks");
  7. height = 0;
  8. }
  9.  
  10. MyClass(int i)
  11. {
  12. System.out.println("Building new House that is "
  13. + i + " feet tall");
  14. height = i;
  15. }
  16.  
  17. void info()
  18. {
  19. System.out.println("House is " + height + " feet tall");
  20. }
  21.  
  22. void info(String s)
  23. {
  24. System.out.println(s + ": House is " + height + " feet tall");
  25. }
  26. }
  27.  
  28. public class MainClass
  29. {
  30. public static void main(String[] args)
  31. {
  32. MyClass t = new MyClass(0);
  33. t.info();
  34. t.info("overloaded method");
  35. //Overloaded constructor:
  36. new MyClass();
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment