下面程序段的输出结果是 class Test{ public static void main(String args[]){ MyThread t=new MyThread(); t.displayOutput("t has been created)); t.start(); } } class MyThread extends Thread{ public void displayOutput(String s){ System.out.println(s); } public void run(){ displayOutput(t is running."); } }
A.t has been created.
B.t has been created. t is running.
C.t is running.
D.编译出错
第1题:
下列程序的运行结果是【 】。
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()
}
第2题:
下面程序的输出结果是( )。 #include<iostream.h> #include"string.h" void main() {char a[]="Hello Test",b[]="Test"; strcpy(a,b); cout<<a<<end1; } A) B)
C) D)
A.Hello
B.Test
C.Hello Test
D.Hello Test HelloTest
第3题:
下面程序段的输出结果是( )。 public class Test { public static void main (String[] args) { for ( int a=0;a<10;a++) { if (a==5) break; System.out.println(A); } } }
A.01234
B.6789
C.012346789
D.5
第4题:
第5题:
下面程序段的输出结果是( )。 public class Test { public static void main (String[] args) { int j=2,i=5; while (j<i--) j++; System.out.println(j);} }
A.2
B.3
C.4
D.5
第6题:
下面程序段的输出结果是( )。 public class Test { public static void main (String[] args) { int n=10; do { System.out.println("n is"+n); }while(--n>10); } }
A.n is 8
B.没有输出
C.n is 10
D.n is 9
第7题:
清在下划线处填入代码,使程序正常运行并且输出“Hello!”
classTesl______{
publicstaticvoidmain(string[]args){
Test=newTest();
t.start();
}
Pubhcvoidrun(){
System.out.println("Hello!");
}
}
第8题:
请阅读下面的程序
classTest/{
privatestaticStringname;
static/{
name="World";
System.out.print(name);
/}
publicstaticvoidmain(String[]args)/{
System.out.print("Hello");
Testtest=newTest();
/}
/}
下列选项中,程序运行结果是()。
:A.World
B.Hello
C.World Hello
D.Hello World
第9题:
下列程序的输出结果是______。 #include<iostream> using namespace std; class Test( public: Test() {cnt++;} ~Test() {cnt--;} static int Count(){return cnt;} private: static int cnt; }; int Test::cnt=0; int main() { cout<<Test::Count()<<""; Test t1,t2; Test*pT3=new Test; Test*pT4=new Test; cout<<Test::Count()<<""; delete pT4; delete pT3; cout<<Test::Count()<<end1; return 0; }
A.024
B.042
C.420
D.240
第10题:
main方法是Java应用程序执行的入口点,下面main方法的方法头合法的是()
A.public static void main()
B.public static void main(String[] args)
C.public static void Main(String[] args)
D.public static int main(String[] args)