首页 > 动物疫病防治员
题目内容 (请给出正确答案)
[主观题]

阅读下面程序class Test implements Runnable{public static void main(String[] args){Tes

阅读下面程序

class Test implements Runnable{

public static void main(String[] args){

Test t = new Test();

t.start();

}

public void run(){ }

}

下列关于上述程序的叙述正确的是

A) 程序不能通过编译,因为 start() 方法在 Test 类中没有定义

B) 程序编译通过,但运行时出错,提示 start() 方法没有定义

C) 程序不能通过编译,因为 run() 方法没有定义方法体

D) 程序编译通过,且运行正常

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“阅读下面程序class Test implements Ru…”相关的问题
第1题
阅读下面的程序public class Test {public static void main(String[] args) {for(int x = 0 ; x <=3 ; x++){continue;System.out.print(x%2);}}}运行结果正确的是
阅读下面的程序public class Test {public static void main(String[] args) {for(int x = 0 ; x<=3 ; x++){continue;System.out.print(x%2);}}}运行结果正确的是

A.跳出循环,无输出

B.0121

C.01

D.0123

点击查看答案
第2题
阅读下面程序 public class Increment{ public static void main(stringargs[]){ int C; c=5

阅读下面程序 public class Increment{ public static void main(stringargs[]){ int C; c=5: System.out.println(c); System.out.println(c++): System.out.println(c); } } 程序运行结果是()。

A.5 6 6

B.5 5 6

C.6 7 7

D.6 6 6

点击查看答案
第3题
阅读下面程序public class MyVal { public static void main(String[]args) { MyVal m=new MyVa

阅读下面程序 public class MyVal { public static void main(String[]args) { MyVal m=new MyVal(); m.amethod(); } public void amethod() { boolean b[]=new Boolean[5]; } } 程序编译或运行的结果是

A.1

B.null

C.""

D.编译不通过

点击查看答案
第4题
阅读下列代码public class Test 2005{public static void main(String args[]){ System.out.prin

阅读下列代码 public class Test 2005{ public static void main(String args[]){ System.out.println((3>2)?4:5); } } 其运行结果是

A.2

B.3

C.4

D.5

点击查看答案
第5题
试题六(共15分)阅读下列说明和Java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。【说明】某发

试题六(共15分)

阅读下列说明和Java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。

【说明】

某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰(Decorator)模式实现打印发票的功能,得到如图6-1所示的类图。

试题六(共15分)阅读下列说明和Java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。【说明

【java代码】

class invoice{

public void printInvoice(){:

System.out.println ("This is the content of the invoice!");

}

}

class Decorator : extends Invoice {

protected Invoice ticket;

public Decorator(lnvoice t){

ticket = t;

}

public void printinvoice(){

if(ticket != NULL)

(1);

}

}

class FootDecorator extends Decorator{

public FootDecorator(lnvoice t){

super(t);

}

public void printinvoice (){

Systent.out.println("This is the header of the invoice! ");

(2) ;

}

}

class FootDecorator extends Decorator {

public FootDecorator(invoice t):{

super(t);

}

public void printlnvoice(){

(3) ;

Systent.out.println("This is the header of the invoice! ");

}

}

Class test {

public static void main(string[] args){

Invoice t =new invioce();

Invoice ticket;

Ticket= (4) ;

Ticket. Printinvoice();

Systent.out.println(“--------------“)

Ticket= (5) ;

Ticket. Printinvoice();

}

}

程序的输出结果为:

This is the header of the invoice!

This is the content of the invoice!

This is the footnote of the invoice!

----------------------------

This is the header of the invoice!

This is the footnote of the invoice!

点击查看答案
第6题
下列程序的运行结果是【 】。 include <iostream. h> 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;

}

点击查看答案
第7题
有如下程序:#include<iostream>using namespace std;class Test{public:Test(){n+=2;}~Test(){n-

有如下程序: #include<iostream> using namespace std; class Test{ public: Test() {n+=2;} ~Test() {n-=3;} static int getNum(){return n;} private: static int n; }; int Test::n=1; int main() { Test* p=new Test; delete p; cout<<"n="<<Test::getNum()<<endl; return0; } 执行后的输出结果是()。

A.n=0

B.n=1

C.n=2

D.n=3

点击查看答案
第8题
下列程序test类中的变量e的最后结果为()。public class test{ public static void main (String a

下列程序test类中的变量e的最后结果为()。 public class test { public static void main (String args[]) { int a=10; int b; int c; if(a>50) { b=9; } c=b+a; } }

A.10

B.0

C.19

D.编译出错

点击查看答案
第9题
关于下面的程序段,说法正确的是import java.awt.*;import java.applet.*;public class Test exte

关于下面的程序段,说法正确的是 import java.awt.*; import java.applet.*; public class Test extends Applet{ Canvas MyCanvas; public void init(){ MyCanvas=new Canvas(); MyCanvas.setBackground(Color.cyan); add(MyCanvas); } }

A.程序可以运行,且看到显示

B.程序编译出错

C.程序可以运行,但看不到显示

D.以上说法都不对

点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改