單項選擇題

What will be the result of attempting to compile and run the following program?()  
public class Q28fd {  
public static void main(String args[]) {  
int counter = 0;  
l1:  
for (int i=10; i<0; i--) {  
l2:  int j = 0;  
while (j < 10) { 
 if (j > i) break l2;  
if (i == j) {  
counter++;  
continue l1;  
}  
}  
counter--;  
}  
System.out.println(counter); 
}  
} 

A.The program will fail to compile.
B.The program will not terminate normally.
C.The program will write 10 to the standard output.
D.The program will write 0 to the standard output.
E.The program will write 9 to the standard output.

題目列表

你可能感興趣的試題

單項選擇題

Which method implementations will write the given string to a file named "file", using UTF8 encoding?()  
IMPLEMENTATION a: 
 public void write(String msg) throws IOException {  
FileWriter fw = new FileWriter(new File("file"));  
fw.write(msg);  
fw.close();  
}  
IMPLEMENTATION b: 
 public void write(String msg) throws IOException { 
 OutputStreamWriter osw =  new OutputStreamWriter(new FileOutputStream("file"), "UTF8");  osw.write(msg);  
osw.close();  
}  
IMPLEMENTATION c:  
public void write(String msg) throws IOException {  FileWriter fw = new FileWriter(new File("file"));  
fw.setEncoding("UTF8");  
fw.write(msg);  
fw.close();  }  
IMPLEMENTATION d:  
public void write(String msg) throws IOException {  FilterWriter fw = FilterWriter(new FileWriter("file"), "UTF8");  
fw.write(msg);  fw.close();  
}  
IMPLEMENTATION e:  
public void write(String msg) throws IOException {  
OutputStreamWriter osw = new OutputStreamWriter(  new OutputStream(new File("file")), "UTF8"  );  
osw.write(msg);  
osw.close();  
}  

A.Implementation a.
B.Implementation b.
C.Implementation c.
D.Implementation d.
E.Implementation e.

微信掃碼免費搜題