网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
Consider the following class:     class Test(int i) {     void test(int i) {  System.out.println(“I am an int.”); }    void test(String s) {   System.out.println(“I am a string.”);     }          public static void main(String args) {    Test t=new Test();     char ch=“y”;    t.test(ch);     }      }     Which of the statements below is true?()
A

 Line 5 will not compile, because void methods cannot be overridden.

B

 Line 12 will not compile, because there is no version of test() that rakes a charargument.

C

 The code will compile but will throw an exception at line 12.

D

 The code will compile and produce the following output: I am an int.

E

 The code will compile and produce the following output: I am a String.


参考答案

参考解析
解析: 在第12行,16位长的char型变量ch在编译时会自动转化为一个32位长的int型,并在运行时传给void test(int i)方法。
更多 “单选题Consider the following class:     class Test(int i) {     void test(int i) {  System.out.println(“I am an int.”); }    void test(String s) {   System.out.println(“I am a string.”);     }          public static void main(String args) {    Test t=new Test();     char ch=“y”;    t.test(ch);     }      }     Which of the statements below is true?()A  Line 5 will not compile, because void methods cannot be overridden.B  Line 12 will not compile, because there is no version of test() that rakes a charargument.C  The code will compile but will throw an exception at line 12.D  The code will compile and produce the following output: I am an int.E  The code will compile and produce the following output: I am a String.” 相关考题
考题 下面程序的运行结果是【】。 inChlde using namespace std; class count { static int n; 下面程序的运行结果是【 】。inChlde<iOStream>using namespace std;class count{static int n;public:count(){n++;}static int test(){for(int i=0:i<4;i++)n++;return n;}};int count::n=0;int main(){cout<<COUnt::test()<<" ";count c1, c2;cout<<count::test()<<end1;return 0;}

考题 下列程序段的输出结果是【 】。public class Test {void printValue(int m) {do {System.out.println("The value is"+m);}while (--m>10);}public static void main (String args[]) {int i=10;Test t= new Test();t.printValue(i);}}

考题 给出下列代码,可放在类A的横线位置作为A合理的内部类的是( )。 class A { protected int i; A(int i) { this.i = i; } ______ }A.class B { }B.class B extends A { }C.class B implements A { }D.class A { }

考题 下面代码段的输出结果为( )。 public class Test { public static void main(String sss[]) { int i=0xFFFFFFFl; int j=~i; } }A.0B.1C.14D.-15

考题 在如下源代码文件Test.java中, 哪个是正确的类定义?() A.public class test { public int x = 0; public test(int x) { this.x = x; } }B.public class Test{ public int x=0; public Test(int x) { this.x = x; } }C.public class Test extends T1, T2 { public int x = 0; public Test (int x) { this.x = x; } }D.public class

考题 下列程序的执行结果是 ( ) public class Test { public int aMethod() { satic int i=0; i++; System.out.println(i); } public static void.main(String args[]) { Test test=new Test(); test.aMethod(); }A.编译错误B.0C.1D.运行成功,但不输出

考题 给出下列的程序段,则哪个选项是类A合理的内部类? ( ) class A{ protected int i; A(int i){ this.i=i;A.classB { }B.class B extendsA { }C.class B extends A{ B(){System.out.println("i="+1);} }D.class A { }

考题 下列程序的运行结果是【 】。 include class test { private: int num; public: tes 下列程序的运行结果是【 】。include <iostream. h>class test{private:int num;public:test()int TEST() {return num+100;}~test()};test::test(){num=0;}test::~test(){cout<<"Destructor is active"<<endl;}void main(){test x[3]cout<<x[1]. TEST()<<endl;}

考题 使用VC6打开考生文件夹下的工程test37_1,此工程包含一个源程序文件test37_1.cpp,但该程序运行有问题,请改正函数中的错误,使该程序的输出结果为:0149 16 25 36 49 64 81源程序文件test37_1.cpp清单如下:include<iostream.h>template <class T, int N = 100> class Vector{T vec[N];public:void set(int pos, T val);T get(iht pos);/***************** found *****************/}template <class T, int N> void Vector<T, N>::set(int pos, T val){vec[pos] = val;}/***************** found *****************/template <class T, int N> Vector<T, N>::get(int pos){return vec[pos];}int main (){Vector<double, 10> v;int i = 0;double d = 0.0;for (i = 0; i < 10; i++)v.set(i, double(i * i));for (i = 0; i < 10; i++)cout<<v.get(i)<<" ";cout<<end1;/***************** found *****************/}

考题 下面程序段的输出结果是 class Base { int i; Base() { add(1); } void add(int v) { i+=v; } void print() { System.out.println(i); } } class Extension extends Base { Extension() { add(2); } void add(int v) { i+=v*2; } } public class Test { public static void main(String args[]) { bogo(new Extension()); } static void bogo(Baseb){ b.add(8); b.print(); } }A.9B.18C.20D.22

考题 给出下列的代码,则下列选项中哪个是类A合理的内部类? class A { protected int i; A(int i) { this.i=i; } }A.class B { }B.class B extends A { }C.class B extends A { B( ){System.out.println("="+i);} }D.class A { }

考题 有以下程序:include using namespace std;class count{ static int n;public: count 有以下程序: #include <iostream> using namespace std; class count { static int n; public: count ( ) { n++; } static int test() { for (int i = 0; i < 4; i++ ) n++; return n; } }; int count :: n = 0; int main() { cout<<count :: test()<<" "; count c1, c2; cout<<count :: test()<<end1; return 0; } 执行后的输出结果是( )。A.4 10B.1 2C.22D.24

考题 给出—卜列的代码,则下列选项中( )可以表示为类A合理的内部类。 class A{ protected int i; A (int i) { this i=i; }}A.class B{ }B.class B extends A{ }C.class B extends A{ B ( ){System.out.println("i="+i);} }D.class A{ }

考题 下列程序的输出结果是 class Demo { void test( ) { Systeme.out.pnnt("NO");} void test(int i) { System.out.print(a);} void test(int a,int b) { System.out.print(a+b);} } class Test { public static void main(String args[ ] ) { Demo de=new Demo( ); de.test( ); de.test(5); de.test(6,8); } }A.No 5 6 8B.5 6 8 NoC.No 5 14D.8 6 No 5

考题 下面程序的运行结果是()。includeusing namespace std;class TestClass{static int n; 下面程序的运行结果是( )。 #include<iostream> using namespace std; class TestClass { static int n; public: TestClass () { n++; } static int test() { for(int i=0;i<4;i++) n++; return n; } }; int TestClass::n=0; int main() { cout<<TestClass::test()<<" "; TestClass c1,c2; cout<<TestClass::test()<<endl; return (); }A.4,10B.4,6C.0,6D.0,4

考题 在下列源代码文件Test.java中, ( )是正确的类定义。A.public class test{B.public class Test{ public int x=0;public int x=0; public test (intx) public Test (int x){ {this.x=x; this.x=x;} }} }C.public class Test extends T1,T2{D.protected class Test extends T2{ public int=0;public int x=0; public Test(int x){Public Test (int x){ this.x=x;this.x=x: }} }}

考题 在下列源代码文件Test.java中,哪个选项是正确的类定义? ( )A.public class test { public int x=0; public test(int x) { this.x=x; } }B.public class Test { public int x=0; public Test(int x) { this.x=x; } }C.public class Test extends Ti,T2 { public int x=0; public Test(int x) { this.x=x; } }D.protected class Test extends T2 { public int x=0; public Test(int x) { this.x=x; } }

考题 下列程序的输出结果是 ( ) class Derao { void test() { Systeme.out.print("NO");} void test (int i) {System.out.print(a);} void test(int a,int b) {System.out.print(a+b);} } class Test { public static void main(String args[]) { Demo de=new Demo(); de.test(); de.test5.; de.test(6,8); } }A.No568B.568NoC.No514D.86No5

考题 Which statements concerning the following code are true?()   class a {   public a() {}   public a(int i) { this(); }   }   class b extends a {   public boolean b(String msg) { return false; }   }   class c extends b  {  private c() { super(); }   public c(String msg) { this(); }   public c(int i) {}   }  A、The code will fail to compile.B、The constructor in a that takes an int as an argument will never be called as a result of constructing an  object of class b or c.C、Class c has three constructors.D、Objects of class b cannot be constructed.E、At most one of the constructors of each class is called as a result of constructing an object of class c.

考题 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、 0B、 1C、 2D、 Compilation fails.

考题 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 8B、 The value is 9C、 The value is 10D、 The value is 11

考题 public class Parent {     int change() {…}     }  class Child extends Parent {     }  Which methods can be added into class Child?()    A、 public int change(){}B、 int chang(int i){}C、 private int change(){}D、 abstract int chang(){}

考题 多选题Which statements concerning the following code are true?()   class a {   public a() {}   public a(int i) { this(); }   }   class b extends a {   public boolean b(String msg) { return false; }   }   class c extends b  {  private c() { super(); }   public c(String msg) { this(); }   public c(int i) {}   }AThe code will fail to compile.BThe constructor in a that takes an int as an argument will never be called as a result of constructing an  object of class b or c.CClass c has three constructors.DObjects of class b cannot be constructed.EAt most one of the constructors of each class is called as a result of constructing an object of class c.

考题 多选题public class Parent {     int change() {…}     }  class Child extends Parent {     }  Which methods can be added into class Child?()Apublic int change(){}Bint chang(int i){}Cprivate int change(){}Dabstract int chang(){}

考题 单选题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  0B  1C  2D  Compilation fails.

考题 单选题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”

考题 单选题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 8B  The value is 9C  The value is 10D  The value is 11