编译和运行下列程序,请选择正确的输出结果______。 public class ex31 { private void test() { System.out.println(6 + 6 + "(Result)"); } public static void main(String[] args) { new ex31().test(); } }
A.12(Result)
B.66(Reslllt)
C.编译时出错,运算符“+”不能实现一个string类型的数据和一个int类型数据的加法运算
D.运行时出错,运算符“+”不能将int类型数据转化为sbing类型
第1题:
下面程序运行时输出结果为【 】。
include<iostream.h>
include<malloc.h>
class Rect
{
public:
Rect(int1,int w)(length=1;width=w;)
void Print(){cout<<"Area:"<<length *width<<endl;)
void *operator new(size-t size){return malloc(size);}
void operator delete(void *p){free(p)
private:
int length,width;
};
void main()
{
Rect*p;
p=new Rect(5,4);
p->Print();
delete p;
}
第2题:
关于下面程序,( )的结论是正确。
publicclassJ_Test{
publicstaticvoidmain(String[]args){
int[]a=newint[5];
boolean[]b=newboolean[5];
System.out.println(a[4]);
System.out.println(b[5]);
}
}
A、程序可以通过编译并正常运行,结果输出“0false”
B、程序可以通过编译并正常运行,结果输出“1true”
C、程序无法通过编译
D、程序可以通过编译,但无法正常运行
第3题:
【单选题】编译运行下面的程序,结果是()。 public class A{ public static void main(String args[]){ B b=new B(); b.test(); } void test(){ System.out.print("A"); } } class B extends A{ void test(){ super.test(); System.out.print("B"); ); } }
A.产生编译错误
B.代码可以编译运行,并输出结果:AB
C.代码可以编译运行,但没有输出
D.编译没有错误,但会产生运行时异常
第4题:
下列程序的运行结果是______。
include<iostream.h>
class test
{
private:
int hum;
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;
}
第5题:
编译运行下面的程序,结果是什么? public class A { public static void main(String[] args) { B b = new B(); b.test(); } void test() { System.out.print("A"); } } class B extends A { void test() { super.test(); System.out.print("B"); } }
A.产生编译错误
B.代码可以编译运行,并输出结果AB
C.代码可以编译运行,但没有输出
D.编译没有错误,但会产生运行时异常
第6题:
6、编译运行下面的程序,结果是什么? public class A { public static void main(String[] args) { B b = new B(); b.test(); } void test() { System.out.print("A"); } } class B extends A { void test() { super.test(); System.out.print("B"); } }
A.产生编译错误
B.代码可以编译运行,并输出结果AB
C.代码可以编译运行,但没有输出
D.编译没有错误,但会产生运行时异常