网站导航:首页 -> JAVA认证 -> JAVA认证考试题库 -> JAVA题库:考考你1

JAVA题库:考考你1

examine the following code which includes an inner class:

 public final class test4{ 

  class inner{ 
    void test(){ 
      if (test4.this.flag);{ 
     sample(); 
      } 
    } 
 }
       private boolean flag=false; 
  

 public void sample(){ 
 system.out.println('sample'); 
 } 

 public test4(){ 
 (new inner()).test(); 
 } 

 public static void main(string args[]){ 
 new test4(); 
 } 
 } 


 what is the result: 
   a.print out “sample”
   b.program produces no output but termiantes correctly.
   c. program does not terminate.
   d.the program will not compile
答案:a