下列代码的编译或执行结果是( )。 public class Myval{ public static void main(string args[]){ MyVal m=new MyVal; aMethod; } public void aMethod{ boolean b[]=new Boolean[5]; System.OUt.println(b[0]); } }
A.1
B.null
C.0
D.编译错误
第1题:
A.age=0
B.age=null
C.age=
D.程序编译错误
第2题:
下列程序的运行结果是______。
include<iostream.h>
class Base
{
public:
void f(int x){cout<<“Base:”<<x<<endl;}
);
class Derived:public Base
{
public:
void f(char*str){cout<<“Derived:”<<str<<endl;}
};
void main(void)
{
Base*pd=ne
第3题:
A.null
B.-1
C.编译时出错
D.运行时报错
第4题:
第5题:
下面程序的结果是 ______。 #include<iostream.h> class A{ public: virtual void fun()=0{}; }; class B:public A{ public: void fun () {cout<< "new file" ;} }; class C: public A{ public: void fun (){cout<<"open file"<< " " } }; class D: public A{ public: void fun () {cout<< "save file\n" ;} }; void main() { A a,*p; B b; C c; D d; p=&c; p->fun (); p=&b; p->fun (); p=&d; p->fun(); }
A.new file open file save file
B.new file new file new file
C.编译出错
D.open file new file save file
第6题:
下列程序的运行结果是【 】。
include <iostream. h>
class SomeClass
{
public:
SomeClass(int value) { some_value=value;};
void show_data(void) { cout<<data<<"<<~some_value<<endl; };
static void set_data(int value) {data=value; }
private:
static int data;
int some_value
};
int SomeClass::data
void main(void)
{
SomeClass my_class(1001),your_class(2002);
your_class. set_data(4004);
my_elass. show_data()
}
第7题:
下列代码的执行结果是( )。 class NextLetter{ public static void main(String[ ]args){ char c="a"; System.out.println("The next character is"+ + + c +"."); } }
A.a
B.b
C.c
D.a+c
第8题:
A."Hello"
B."good-bye"
C."Hello""god-bye"
D.代码不能编译
第9题:
第10题:
给出以下代码,请问该程序的运行结果是什么? class Example{ public static void main(String[] args){ int a = 5; System.out.println(cube(a)); } int cube(int theNum){ return theNum*theNum*theNum; } } 请选择一个正确答案:
A.代码编译失败,因为方法cube()已经在java.lang.Math类上定义过
B.代码编译失败,因为方法cube()不是static方法。
C.代码编译成功,但运行期抛出异常。
D.打印输出125。