可学答题网 > 问答 > SCJP程序员认证考试题库
目录: 标题| 题干| 答案| 搜索| 相关
问题

Given the following co


Given the following code:    public class Test {  void printValue(int m){  do {  System.out.println("The value is"+m);     }  while( --m > 10 )     }  public static void main(String arg[]) {     int i=10;  Test t= new Test();     t.printValue(i);     }     }  Which will be output?()    

  • A The value is 8
  • B The value is 9
  • C The value is 10
  • D The value is 11
参考答案
参考解析:

此题考察的是do… while循环和 -- 操作符的知识,do…while最少被执行一次,在执行完do中的内容后判断while中的条件是否为true,如果为true的话就再执行do中的内容,然后再进行判断,以此类推直到while的判断为false时退出循环执行循环后面的内容,而—操作符的规则是在变量右边的-- 将先进行运算,然后才是使变量的值减一,而在变量左边的是先将变量的值减一再运算。

分类:SCJP程序员认证考试题库
相关推荐

1、Given the following sc

Given the following scripts, both found in /usr/local/bin, what would the output be when exec...

2、Given the following in

Given the following interface definition, which definitions are valid?()  interface I {  vo...

3、Given the following co

Given the following code fragment:    public void create() {    Vector myVect;&en...

4、Given the following co

Given the following code, which code fragments, when inserted at the indicated location, will&ens...

5、Given the following co

Given the following code:    public class Person{    int arr[] = new int[10];&...

6、Given the following co

Given the following code:    public class Person{ static int arr[] = new int[10]; p...