单选题public class test (      private static int j = 0;  private static boolean methodB(int k) (  j += k;  return true;  )  public static void methodA(int  i)(  boolean b:     b = i < 10 | methodB (4);  b = i < 10 || methodB (8);  )  public static void main

题目
单选题
public class test (      private static int j = 0;  private static boolean methodB(int k) (  j += k;  return true;  )  public static void methodA(int  i)(  boolean b:     b = i < 10 | methodB (4);  b = i < 10 || methodB (8);  )  public static void main (String args[])(   methodA (0);  system.out.printIn(j);  )  )   What is the result?()
A

 The program prints “0”

B

 The program prints “4”

C

 The program prints “8”

D

 The program prints “12”

E

 The code does not complete.


相似考题
更多“单选题public class test (      private static int j = 0;  private static boolean methodB(int k) (  j += k;  return true;  )  public static void methodA(int  i)(  boolean b:     b = i  10 | methodB (4);  b = i  10 || methodB (8);  )  public static void main (”相关问题
  • 第1题:

    有以下程序:include using namespace std;class A{private:int a;public:A (int i){a

    有以下程序: #include <iostream> using namespace std; class A { private: int a; public: A (int i) { a=i; } void disp() { cout<<a<<","; } }; class B { private: int b; public: B(int j) { b=j; } void disp() { cout<<b<<","; } }; class C : public B,public A { private: int c; public: C(int k) :A(k-2),B(k+2) { c=k; } void disp () { A::disp (); B::disp (); cout<<c<<endl; } }; int main () { C obi (10); obj.disp (); return 0; } 程序执行后的输出结果是

    A.10,10,10

    B.10,12,14

    C.8,10,12

    D.8,12,10


    正确答案:D
    解析:本题考核派生类构造函数的使用。本题中,派生类C具有多重继承关系,所以在派生类C的构造函数中应该包含基类A和B的成员初始化列表。

  • 第2题:

    下面语句执行后,i的值是______。 public class Test11 { public static void main(String[] args) { int i=0; for( int j=10; j>5&&i<5; j-=3,i+=2 ) { i=i+j; } System.out.println (i); } }

    A.10

    B.9

    C.8

    D.12


    正确答案:D
    解析:变量i和j的初始值分别为0和10,判断结束条件j>5&&i5为true,执行i=i+j;得到i=10,再做j-=3和i+=2,分别得到i=12和j=7,判断结束条件j>5&&i5为false,停止循环,因此i的值为12,正确答案为D。

  • 第3题:

    下列程序执行后的结果是______。

    public class ex24

    {

    public static void main(String[] args)

    {

    int j=10;

    a1: for(int i=3;i>0;i--)

    {

    j-=i;

    int m=l;

    a2: while (m<j)

    {

    if (i<=m)

    continue a1;

    j/=m++;

    }

    }

    System.out.println(j);

    }

    }

    下列嵌套的循环程序执行后,结果是______。 public class ax25 { public static void main(String[] args) { int sum=0; for(int i=0;i<=5;i++) { for(int j=10;j>3*i;j--) { sum+=j*i; } } System.out.println(sum); } }

    A.136

    B.127

    C.147

    D.153


    正确答案:C

  • 第4题:

    下列程序输出结果为( )。 public class test { public static void main (String args[]) { int a=0; outer:for(int i=0;i<2;i + +) { for(int j=0;j<2;j+ +) { if(j>i) { continue outer; } a+ +; } } System.out.println(a); } }

    A.0

    B.2

    C.3

    D.4


    正确答案:C

  • 第5题:

    若有以下程序:include using namespacestd;class A {private: int a;public:A(int i)

    若有以下程序: #include <iostream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp() { cout <<a<<","; } }; class B { private: int b; public: B(int j) { b=j; } void disp() { cout<<b<<","; } }; class C: public B,public A { private: int c; public: C(int k):A(k-2),B(k+2) { c=k; } void disp() { A::disp(); B::disp(); cout<<c<<end1; } }; int main() { C obj (10); obj.disp(); return 0; } 程序执行后的输出结果是

    A.10,10,10

    B.10, 12,14

    C.8,10,12

    D.8,12,10


    正确答案:D
    解析:本题考核派生类构造函数的使用。本题中,派生类C具有多重继承关系,所以在派生类C的构造函数中应该包含基类A和B的成员初始化列表。

  • 第6题:

    执行下列程序段之后,变量b的值为______。 public class Test9 { public static void main(String[] args) { int i=12; int j=24; boolean b1=true; boolean b=(j%i== 0)&&(!b1) ||(j/i!=2); System.out.println(b); } }

    A.true

    B.假

    C.1

    D.0


    正确答案:B
    解析:表达式执行次序为:首先做!b1得到false:然后做j%i==0得到true;再做j/i!=2得到false:然后做&&得到false;最后是||得到false。

  • 第7题:

    public class TestDemo{   private int x = 2;  static int y = 3;  public void method(){     final int i=100;     int j = 10;      class Cinner{  public void mymethod(){  //Here       }    } } }  在Here处可以访问的变量是哪些?() 

    • A、x
    • B、 y
    • C、 i
    • D、 j

    正确答案:A,B,C

  • 第8题:

    public class Delta {  static boolean foo(char c) {  System.out.print(c);  return true;  }  public static void main( String[] argv ) {  int i =0;  for ( foo(‘A’); foo(‘B’)&&(i<2); foo(‘C’)){  i++ ;  foo(‘D’);  }  }  }  What is the result?()  

    • A、 ABDCBDCB
    • B、 ABCDABCD
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:A

  • 第9题:

    public class Test {  public int aMethod() {  static int i = 0;  i++;  return i;  }  public static void main (String args[]) {  Test test = new Test();  test.aMethod();  int j = test.aMethod();  System.out.println(j);  }  }  What is the result?()  

    • A、 0
    • B、 1
    • C、 2
    • D、 Compilation fails.

    正确答案:D

  • 第10题:

    多选题
    现有:  public  class  TestDemo{     private int X-2;      static int y=3;  public  void method(){      final int i=100;      int j  =10;     class Cinner {  public void mymethod(){      //Here     }     }     }     } 在Here处可以访问的变量是哪些?()
    A

    X

    B

    y

    C

    j

    D

    i


    正确答案: B,A
    解析: 暂无解析

  • 第11题:

    单选题
    public class test(  public int aMethod()[  static int i=0;  i++;  return I;  )  public static void main (String args[]){  test test = new test();  test.aMethod();  int j = test.aMethod();  System.out.printIn(j);  ]  }        What is the result?()
    A

     Compilation will fail.

    B

     Compilation will succeed and the program will print “0”

    C

     Compilation will succeed and the program will print “1”

    D

     Compilation will succeed and the program will print “2”


    正确答案: B
    解析: 暂无解析

  • 第12题:

    多选题
    public class TestDemo{   private int x = 2;  static int y = 3;  public void method(){     final int i=100;     int j = 10;      class Cinner{  public void mymethod(){  //Here       }    } } }  在Here处可以访问的变量是哪些?()
    A

    x

    B

    y

    C

    i

    D

    j


    正确答案: A,C
    解析: 暂无解析

  • 第13题:

    执行下列程序段之后,变量b的值为( )。 public class Test { public static void main (String[] args) { int i = 12; int j = 24; boolean b1 = true; booleanb=(j%i==0)&&(! b1) || (j/i! =2); System. out. println (B); } }

    A.true

    B.false

    C.0

    D.1


    正确答案:B
    解析:表达式执行次序为:首先做!b1得到false;然后做j%i==0得到true;再做j/i!=2得到false;然后做&&得到false;最后是||,得到false。

  • 第14题:

    若有以下程序:include using namespace std;class A{private:int a;public:A(im i){a

    若有以下程序: #include <iostream> using namespace std; class A { private: int a; public: A(im i) { a=i; } void disp() cout<<a<<","; } }; class B { private: int b; public: B(int j) { b=j; } void disp0 { cout<<b<<","; } }; class C: public B,public A { private: int c; public: C(int k):A(k-2),B(k+2) { c=k; } void disp0 { A::disp(); B::disp(); cout<<c<<endl; } }; int main() { C obj(10); obj.disp(); return 0; } 程序执行后的输出结果是( )。

    A.10,10,10

    B.10,12,14

    C.8,10,12

    D.8,12,10


    正确答案:D

  • 第15题:

    下列程序输出结果为( )。public class test { public static void main(String args[]) { int a=0; outer: for(int i=0;i<2;i++) { for(int j=0;j<2;j++) { if(j>i) { continue outer; } a++; } } System.out.println(a); }}

    A.0

    B.2

    C.3

    D.4


    正确答案:C

  • 第16题:

    若有以下程序:include using namespace std;class A{private:int a;public:A(int i){

    若有以下程序: #include <iostream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp () { cout<<a<<","; } }; class B { private: int b; public: B(int j) { b=j; } void disp () { cout<<b<<","; } }; class C : public B,public A { private: int c; public: C(int k):A(k-2),B(k+2) { c=k; } void disp () { A::disp(); B::disp(); cout<<c<<endl; } }; int main() { C obj(10); obj.disp(); return 0; }

    A.10,10,10

    B.10,12,14

    C.8,10,12

    D.8,12,10


    正确答案:D
    解析:本题考核派生类构造函数的使用。本题中,派生类c具有多重继承关系,所以在派生类C的构造函数中应该包含基类A和B的成员初始化列表。

  • 第17题:

    下列语句执行后,i的值是( )。 public class Test { public static void main(String[ ] args) { int i =0; for(int j=10; j>5&&i<5; j-=3,i+=2) i=i+j; System.out.println(i); } }

    A.8

    B.9

    C.10

    D.12


    正确答案:D
    解析:变量i和j的初始值分别为0和10,判断结束条件j>5&&i5为true,执行i=i+j;得到i=10,再做j-=3和i+=2,分别得到i=12和j=7,判断结束条件j>5&&i5为false,停止循环,因此i的值为12,正确答案为D。

  • 第18题:

    现有:  public  class  TestDemo{     private int X-2;      static int y=3;  public  void method(){      final int i=100;      int j  =10;     class Cinner {  public void mymethod(){      //Here     }     }     }     } 在Here处可以访问的变量是哪些?() 

    • A、X
    • B、y
    • C、j
    • D、i

    正确答案:A,B,D

  • 第19题:

    public class Test {  public static void leftshift(int i, int j) {  i<<=j;  }  public static void main(String args[])  {  int i = 4, j = 2;  leftshift(i, j);   System.out.printIn(i); }  }     What is the result?()  

    • A、 2
    • B、 4
    • C、 8
    • D、 16
    • E、 The code will not compile.

    正确答案:B

  • 第20题:

    public class test(    public int aMethod()[   static int i=0;   i++;   return I;   )    public static void main (String args){   test test = new test();    test.aMethod();   int j = test.aMethod();   System.out.printIn(j);   ]  }   What is the result?()

    • A、 Compilation will fail.
    • B、 Compilation will succeed and the program will print “0”
    • C、 Compilation will succeed and the program will print “1”
    • D、 Compilation will succeed and the program will print “2”

    正确答案:D

  • 第21题:

    public class test (      private static int j = 0;  private static boolean methodB(int k) (  j += k;  return true;  )  public static void methodA(int  i)(  boolean b:     b = i < 10 | methodB (4);  b = i < 10 || methodB (8);  )  public static void main (String args[])(   methodA (0);  system.out.printIn(j);  )  )   What is the result?()  

    • A、 The program prints “0”
    • B、 The program prints “4”
    • C、 The program prints “8”
    • D、 The program prints “12”
    • E、 The code does not complete.

    正确答案:B

  • 第22题:

    单选题
    public class Test {  public int aMethod() {  static int i = 0;  i++;  return i;  }  public static void main (String args[]) {  Test test = new Test();  test.aMethod();  int j = test.aMethod();  System.out.println(j);  }  }  What is the result?()
    A

     0

    B

     1

    C

     2

    D

     Compilation fails.


    正确答案: D
    解析: 暂无解析

  • 第23题:

    单选题
    public class Test {  public static void leftshift(int i, int j) {  i<<=j;  }  public static void main(String args[])  {  int i = 4, j = 2;  leftshift(i, j);   System.out.printIn(i); }  }     What is the result?()
    A

     2

    B

     4

    C

     8

    D

     16

    E

     The code will not compile.


    正确答案: C
    解析: 暂无解析