Advertisement
kpfp_linux

Bardzo zły test. Bardzo.

Nov 15th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.24 KB | None | 0 0
  1.  
  2.  
  3.  
  4. public class Test {
  5.    
  6.     public int fib6() {
  7.         System.out.println("Fib6 start");
  8.         try {
  9.             return rr = 8;
  10.         } finally {
  11.             System.out.println("Fib6 end");
  12.         }
  13.     }
  14.    
  15.     @SuppressWarnings("finally")
  16.     public int fib7() {
  17.         try {
  18.             System.out.println("Fib7 start");
  19.             try {
  20.                 Integer a = null;
  21.                 @SuppressWarnings("null")
  22.                 int b = a;
  23.                 return b;
  24.             } catch (Exception e) {
  25.                 System.out.println("Exception");
  26.             }
  27.         } finally {
  28.             System.out.println("Fib7 end");
  29.             return 13;
  30.         }
  31.     }
  32.    
  33.     int rr = 2;
  34.     {
  35.         rr = 3;
  36.         System.out.println("Static initializer (1)");
  37.     }
  38.    
  39.     Test() {
  40.         System.out.println("Konstruktor (1) start");
  41.         System.out.println("Konstruktor (1) end");
  42.     }
  43.    
  44.     Test(int k) {
  45.         rr = k;
  46.         System.out.println("Konstruktor (2) start");
  47.         System.out.println("Konstruktor (2) end");
  48.     }
  49.    
  50.     {
  51.         rr = 5;
  52.         System.out.println("Static initializer (2)");
  53.     }
  54.    
  55.     public static void main(String[] args) {
  56.         Helper.registerShutdownHook();
  57.         System.out.println("Hello start");
  58.         Test test = new Test();
  59.         int res = test.fib6();
  60.         System.out.println("---> " + String.valueOf(res));
  61.         int res2 = test.fib7();
  62.         System.out.println("---> " + String.valueOf(res2));
  63.         System.out.println("Hello end");
  64.     }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement