nickhumphrey

Java SE 7 Programmer I Certification, Sample Question #1

Nov 25th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. /*
  2. Question:
  3. What is the order of the output statements below when the "main" method gets run?
  4.  
  5. Answer [DON'T CHEAT ;)]:
  6. http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=303&p_certName=SQ1Z0_803
  7. */
  8.  
  9. public class Sequence {
  10.     Sequence() {
  11.         System.out.print("c ");
  12.     }
  13.  
  14.     {
  15.         System.out.print("y ");
  16.     }
  17.  
  18.     public static void main(String[] args) {
  19.         new Sequence().go();
  20.     }
  21.  
  22.     void go() {
  23.         System.out.print("g ");
  24.     }
  25.  
  26.     static {
  27.         System.out.print("x ");
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment