1. class Test{ 2. private Demo d; 3. void start(){ 4. d=new Demo(); 5. this.takeDemo(d); 6. } 7. 8. void takeDemo(Demo demo){ 9. demo=null; 10. demo=new Demo(); 11. } 12. }
Show comments for this question (0) Add comments Link to this question
11. Float f=new Float(“12”); 12. switch(f){ 13. case 12:System.out.println(“Twelve”); 14. case 0:System.out.println(“Zero”); 15. default: System.out.println(“Default”); 16. }
1. public class Examsheets{ 2. static String s; 3. public static void main(String[]args){ 4. System.out.println(“s=”+s); 5. } 6. }
11. public void test(int x){ 12. int odd=x%2; 13. if(odd){ 14. System.out.println(“odd”); 15. }else{ 16. System.out.println(“even”); 17. } 18. }
1. public class ExceptionTest{ 2. class TestException extends Exception{} 3. public void runTest()throws TestExcpetion{} 4. public void test()/*Point X*/{ 5. runTest(); 6. } 7. }
1. public class Test{ 2. public static void main(String[]args){ 3. int x=0; 4. assert(x>0)?”assertion failed”:”assertion failed”; 5. System.out.println(“Finished”); 6. } 7. }
1. public class X{ 2. public static void main(String[]args){ 3. try{ 4. badMethod(); 5. System.out.print(“A”); 6. } 7. catch(Exception ex){ 8. System.out.print(“B”); 9. } 10. finally{ 11. System.out.print(“C”); 12. } 13. Sytstem.out.print(“D”); 14. } 15. public static void badMethod(){ 16. throw new RuntimeException(); 17. } 18. }