以下装箱、拆箱语句中,错误的有()A、 object obj=100;  int m=(int)obj;B、 object obj=100;  int m=obj;C、 object obj=(int)100;  int m=(int)obj;D、 object obj=(object)100;  int m=(int)obj;

以下装箱、拆箱语句中,错误的有()

  • A、 object obj=100;  int m=(int)obj;
  • B、 object obj=100;  int m=obj;
  • C、 object obj=(int)100;  int m=(int)obj;
  • D、 object obj=(object)100;  int m=(int)obj;

相关考题:

有如下程序#includeusing namespace std;class Obj{static int i;public:Obj(){i++;}~Obj(){i--;}static int getVal(){teturn i;}};int Obj::i=0;void f (){Obj ob2;coutObj obl;F();Obj*ob3=new Obj;coutDelete ob3;cout}程序的输出结果是______。A.232B.231C.222D.221

( 29 ) 有如下程序 :#includeusing namespace std;class Obj{static int i;public:Obj( ){ i++; }~Obj( ){ i--; }static int getVal( ){ return i;}};int Obj::i=0;void f(){Obj ob2; coutint main( ){Obj ob1;f( );Obj *ob3=new Obj; coutgetVal( );delete ob3; cout return 0;}程序的输出结果是A ) 232B ) 231C ) 222D ) 221

有如下程序: include using namespace std; class Obj { static in 有如下程序: #include <iostream> using namespace std; class Obj { static int i; public: Obj( ){i++;} ~Obj(){i--;} static int getVal( ){ return i;} }; int Obj::i=0; void f() {Obj ob2; cout<<ob2.getVal( ); } int main( ){ Obj ob1; f(); Obj *ob3=ew Obj; cout<<ob3->getVal( ); delete ob3; cout<<Obj::getVal( ); return 0; } 程序的输出结果是A.232B.231C.222D.221

下面程序段的输出结果为 public class Test { int a,b; Test() { a=100; b=200; } Test(int x,int y) { a=x; b=y; } public static void main(String args[]) { Test Obj1=new Test(12,45); System.out.println(”a=”+Obj 1.a+” b=”+Obj 1.b); Test Obj2=new Test(); System.out.println(”a=”+Obj 2.a+” b=”+Obj 2.b); } }A.a=100 b=200 a=12 b=45B.a=12 b=45 a=100 b=200C.a=12 b=200 a=100 b=45D.a=100 b=45 a=12 b=200

使用VC6打开考生文件夹下的工程proj1。此工程包含一个源程序文件mainl.cpp,但该程序运行有问题。请改正主函数中的错误,使程序的输出结果是:member = 0member = 5member = 10源程序文件 mainl.cpp 清单如下://mainl.cppinclude <iostream>using namespace std;class MyClass{public:MyClass(int i){member=i;}void SetMember(int m){member=m;}int GetMember()const{return member;}void Print() const{cout<<"member="<<member<<end1;}private:int member;};int main(){/***************found***********/MyClass obj1;obj1. Print();MyClass obj2(3);/***************found***********/obj1.member = 5;/***************found***********/MyClass. SetMember(10);obj1. Print();obj2. Print();return 0;}

public static void main(String[]args){12.Object obj=new int[]{1,2,3};13.int[] someArray=(int[])obj;14.for(inti:someArray)System.out.print(i+)15.}What is the result?() A.123B.Compilation fails because of an error in line 12.C.Compilation fails because of an error in line 13.D.Compilation fails because of an error in line 14.E.A ClassCastException is thrown at runtime.

有如下程序:includeusing namespace std;class TestClass{static int i;public:TestC 有如下程序: #include<iostream> using namespace std; class TestClass{ static int i; public: TestClass(){i++;} ~TestClass(){i--;} static int getVal(){return i;} }; int TestClass::i=0; void f(){TestClass obj2;cout<<obj2.getVal();} int main(){ TestClass obj 1; f(); TestClass *obj3=new TestClass;cout<<obj3->getVal(); delete obj3;cout<<TestClass::getVal(); return 0; } 程序的输出结果是( )。A.232B.221C.222D.231

有如下程序:include using namespace std;class Obj { static int i;public:Obj(){i+ 有如下程序:#include <iostream>using namespace std;class Obj { static int i;public: Obj(){i++;} -Obj(){i--;} static int getVal(){return i;} };int Obj::i=0;void f(){Obj ob2; cout<<ob2.getVal(); }hat main(){ Obj ob1; f(); Obj *ob3=new Obj; cout<<ob3->getVal(); delete ob3; cout<<Obj:: getVal(); return (); }程序的输出结果是( )。A.232B.231C.222D.221

把一个对象写到一个流中相对比较简单,具体是通过调用ObjectOutputStream类的writeObject()方法实现的,那么该方法的定义为( )。A.public final int writeObject(Object obj) throws IOExceptionB.public final void writeObject(Object obj) throws IOExceptionC.public Object writeObject(Object obj) throws IOExceptionD.public final Object writeObject(Object obj) throws IOException

若有以下程序:include using namespace std;class A{private:int x;public:int z;voi 若有以下程序:#include <iostream>using namespace std;class A{private: int x;public: int z; void setx(int i) { x=i; } int getx() { return x; }};class B: public A{private: int m;public: int p; void setvalue(int a, int b, int c) { setx(a); z=b; m=c; } void display() { cout<<getx()<<","<<z<<","<<m<<end1; }};int main(){ B obj; obj.setvalue(2,3,4); obj.display(); return 0;程序运行以后的输出结果是( )A.产生语法错误B.2,3,4C.2,2,2D.4,3,2

阅读以下程序:includeclass kk{int m;public:static int n;kk(){m=0;1void setvalu 阅读以下程序: #include<iostream.h> class kk { int m; public: static int n; kk() { m=0; 1 void setvalue() { m++; n++; } void output() { cout<<"m="<<m<<",n="<<n<<endl; } }; int kk::n; void main() { kk obj1,obj2; obi1.Setvalue(); obj1.output(); obj2.setValue(); Obj2.output(); } 该程序的执行结果是( )。A.m=1,n=1B.m=l,n=l m=1,n=1 m=1,n=2C.m=1,n=1D.m=1,n=1 m=2,n=1 m=2,n=2

有如下程序: #includeiostream using namespace std; class Obj{ static int i; public: Obj{i++;} 一Obj{i一一;} static int getVal{return i;} }; int Obj::i=0: void f{Obj ob2;coutob2.getVal;} int main{ Obj obl; f; Obj}ob3=new Obj;coutob3一getVal; delete ob3;coutObj::getVal; return 0; } 执行这个程序的输出结果是( )。A.232B.231C.222D.221

有如下程序 public class Test { int a,b; Test ( ) { a = 100; b = 200; } Test(int x, int y) { a = x; b = y; } public static void main(String args[]) { Test Obj1 = new Test(12,45); System.out.println("a = "Obj1.a+" b = "+ObB) ; Test Obj1 = new Test(); System.out.println("a = "Obj1.a+" b = "+Obj1.B) ; } } 程序的运行结果为( )。A.a=100 b=200 a=12 b=45B.a=12 b=45 a=100 b=200C.a=12 b=200 a=100 b=45D.a=100 b=45 a=12 b=200

若有以下程序: #include 〈iostream〉 using namespace std; class A { private: int x; public: int z; void setx(int i) { x=i; } int getx () { return x; } }; class B : public A { private: int m; public: int p; void setvalue(int a,int b, int C) { setx (A) ; z=b; m=c; } void display() { cout〈〈getx()〈〈","〈〈z〈〈","〈〈m〈〈end1; } }; int main ( ) { B obj; obj.setvalue(2,3,4); obj.display(); return 0; } 程序运行以后的输出结果是( )。A.产生语法错误B.2,3,4C.2,2,2D.4,3,2

includeiostreamincludestringusing namespace std;class MyClass{public:MyClass(int i=0){member=i;}void SetMember(const string m){member=big+m;m=member;}string GetMember(){return member;}void print()const{coutStu:memberendl;}private:string member;};void main(){MyClass obj1,*obj2;string i=wang lin;obj2=obj1;obj2-SetMember(i);obj1.print();}

下面程序段的输出结果为 public class Test { int a, b; Test() { a=100; b=200; } Test(int x,int y) { a=x; b=y; } public static void main(String args[]) { Test Obj1=new Test(12,45); System.out.println("a=+Obj1.a+" b="+Obj1.B) ; Test Obj2=new Test(); System.out.println("="+Obja+" b="+ObjB) ; } }A.a=100 b=200 a=12 b=45B.a=12 b=45 a=100 b=200C.a=12 b=200 a=100 b=45D.a=100 b=45 a=12 b=200

若有以下程序:includeusing namespace std;class A{private:int x;public:int z;void 若有以下程序:#include<iostream>using namespace std;class A {private: int x;public: int z; void setx(int i) { x=i; } int getx () { return x; }}:class B : public A{private: int m;public: int p; void setvalue(int a, int b, int c) { setx(a) ; z=b; m=c; } void display{) { cout<<getx ()<<", "<<z<<", "<<m<<end1; }};int main(){ B obj; obj. setvalue(2,3,4); obj.display(); return 0;} 程序运行以后的输出结果是A.产生语法错误B.2,3,4C.2,2,2D.4,3,2

有以下程序includeusing namespace std;class MyClass{public:MyClass(int n){number 有以下程序 #include<iostream> using namespace std; class MyClass { public: MyClass(int n){number =n; } //拷贝构造函数 MyClass(MyClass other) {number=other.number;} ~MyClass() {} private: int number; }; MyClass fun(MyClass p) { MyClass temp(p); return temp; } int main() { MyClass Obj1(10),obj2(0); MyClass obj3(obj1); obj2=fun(obj3); return 0; } 程序执行时,MyClass类的拷贝构造函数被调用的次数是A.5B.4C.3D.2

以下程序的执行结果为()。includeclass myClass{Dublic:myClass(intdata) ;myClass( 以下程序的执行结果为( )。 #include<iostream.h> class myClass { Dublic: myClass(int data) ; myClass(){value=0; }; myClass(myClass obj); void print(){ cout<<value<<end1; } ~myClass(){} private: int value; }; myClass::myClass(int data) {value=data; } myClass::myClass(myClass Obj) { value=obj.value; } void main() { myClass a(100); myClass b(a) ; b.print(); }A.0B.100C.10D.程序编译时出错

下列程序编译错误,是由于划线处缺少某个语句,该语句是______。 include class A { pr 下列程序编译错误,是由于划线处缺少某个语句,该语句是______。include<iostream.h>class A{private:int numl;public:A( ):numl(0){}A(int i):numl(i){}};class B{private:int num2;public:B( ):num2(0){}B(int i):num2(i){}int my_math(A obj1, B obj2);};int B::my_math(A obj1,B obj2){return(obj1.numl+obj2.num2);}void main(void){A objl(4);B obj,obj2(5);cout<<"obj1+obj2:"<<obj.my_math(obj1,obj2);}

11. public static void main(String[] args) {  12. Object obj =new int[] { 1,2,3 };  13. int[] someArray = (int[])obj;  14. for (int i: someArray) System.out.print(i +“ “)  15. }  What is the result? ()A、 1 2 3B、 Compilation fails because of an error in line 12.C、 Compilation fails because of an error in line 13.D、 Compilation fails because of an error in line 14.E、 A ClassCastException is thrown at runtime.

获取单列集合中元素的个数可以使用以下哪个方法?()A、length()B、size()C、get(int index)D、add(Object obj)

11.public static void main(String[]args){ 12.Object obj=new int[]{1,2,3}; 13.int[] someArray=(int[])obj; 14.for(inti:someArray)System.out.print(i+"") 15.} What is the result?()A、123B、Compilation fails because of an error in line 12.C、Compilation fails because of an error in line 13.D、Compilation fails because of an error in line 14.E、A ClassCastException is thrown at runtime.

单选题以下装箱、拆箱语句中,错误的有()A object obj=100;  int m=(int)obj;B object obj=100;  int m=obj;C object obj=(int)100;  int m=(int)obj;D object obj=(object)100;  int m=(int)obj;

单选题获取单列集合中元素的个数可以使用以下哪个方法?()Alength()Bsize()Cget(int index)Dadd(Object obj)

单选题Given:   11. public static void main(String[] args) {   12. Object obj = new int[] { 1, 2, 3 };   13. int[] someArray = (int[])obj;   14. for (int i : someArray) System.out.print(i + " ");   15. }   What is the result? ()A Compilation fails because of an error in line 13.B A ClassCastException is thrown at runtime.C 1 2 3D Compilation fails because of an error in line 14.E Compilation fails because of an error in line 12.

单选题11.public static void main(String[]args){ 12.Object obj=new int[]{1,2,3}; 13.int[] someArray=(int[])obj; 14.for(inti:someArray)System.out.print(i+"") 15.} What is the result?()A123BCompilation fails because of an error in line 12.CCompilation fails because of an error in line 13.DCompilation fails because of an error in line 14.EA ClassCastException is thrown at runtime.