Guest User

Untitled

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