Guest User

Untitled

a guest
Jun 19th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <script>
  2. function interact()
  3. {
  4. var name = prompt("What is your name?");
  5. alert("Hi, " + name);
  6. }
  7. </script>
  8. <button onclick="interact()">Interact</button>
  9.  
  10. //An innocuous looking method which will become known as a callback method
  11. //because of the way in which we will invoke it.
  12. int meaningOfLife(void) {
  13. return 42;
  14. }
  15.  
  16.  
  17. //An innocuous looking method which just takes an int and prints it to screen
  18. void Print_A_Number(int a_Number) {
  19. System.out.print(a_Number);
  20. }
  21.  
  22. //invoking a method which passes another method as an argument in reaction to an event (the 'another' method - meaningOfLife - is therefore called a callback method) and the event - main() - is that the program is starting
  23. void main() {
  24. Print_A_Number(meaningOfLife);
  25. }
Add Comment
Please, Sign In to add comment