首页 > 高职专科
题目内容 (请给出正确答案)
[单选题]

阅读下列代码:public class Arrays {public static void main(String[ ] args) {int[ ] a = new int[5];for (int i = 0; i<a.length; i++){a[i]=10+i;}for (int i = 0; i<a.length; i++){System.out.println(a[i]);}String[ ] s = {“Frank”, “Bob”, “Jim”};for(int i = 0; i<s.length; i = i + 1){System.out.println(s[i]);}s[2] = “Mike”;System.out.println(s[2]);} }代码运行结果正确的是()

A.10 11 12 13 14 Mike Bob Frank Jim

B.1112 13 14 15 Frank Bob Mike Jim

C.10 11 12 13 14 Frank Bob Jim Mike

D.1112131415MikeJimBobFrank

答案
收藏

C、10 11 12 13 14 Frank Bob Jim Mike

如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“阅读下列代码:public class Arrays {pu…”相关的问题
第1题
试题六(共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!

点击查看答案
第2题
阅读下面代码: import java.awt.*; public class Exam11_2 { public static
void main (String args[]) { ______; f.add("North",new Button("North")); f.add("South",new Button("South")); f.add("East",new Button("East"));; f.add("West",new Button("West")); f.add("Center",new Button("Center")); f.pack(); f.setVisible(true); } } 请在程序中的画线处添上适当的语句【 】,使程序能正确执行。

点击查看答案
第3题
阅读下面代码: import java.awt.*; public class Examll_2 { public static v
oid main(String args[]) { ______; f.add("North",new Button("North")); f.add("South",new Button("South")); f.add("East",new Button ("East")) ;; f.add("West",new Button("West")); f.add("Center",new Button ("Center")); f.pack (); f.setVisible(true); } } 请在程序中的画线处添上适当的语句【 】,使程序能正确执行。

点击查看答案
第4题
请阅读代码: import iava.awt.*; public class E11_4 { public static void m
ain(String args[]) { Frame. f=new Frame("BorderLayout"); ______; f.add("North",new Button("North")); f.add("East",new Button("East")); f.add("West",new Button("West")); f.add("South",tf); f.setSize(200,200); f.pack(); f.setVisible(true); } } 请将程序画线处填入正确的语句【 】,使得程序能够正确运行。

点击查看答案
第5题
阅读下面代码: import java.awt.*; public class Exam11_1 { private Frame.
f; private Button bl,b2,b3,b4; public static void main(String args[] { Exam11_1 that = new Exam11_1 (); that.go(); } public void go () { ______; f.setLayout(new FlowLayout());; bl = new Button ("Button 1"); b2 = new Button ("Button 2"); b3 = new Button ("Button 3"); b4 = new Button ("Button 4"); f.add(b1); f.add(b2); f.add(b3); f.add(b4); f.pack(); f.setVisible(true); } } 请在程序中画线处填写正确的语句【 】,以便编译运行程序后得到正确的结果。

点击查看答案
第6题
下列代码编译和执行后的结果是()。public class Test {public void myMethod(Object o) {Syste

A.代码不打印任何东西

B.代码打印出"My String"

C.代码打印出"My Object"

D.代码抛出一个Runtime的异常

点击查看答案
第7题
下列代码的执行结果是 public class Test{ public int aMethod() { static int i=0;

下列代码的执行结果是 public class Test{ public int aMethod() { static int i=0; i+ +; System.out.println(i); } public static void main(String args[ ]){ Test test = new Test(); test.aMethod(); } }

A.编译错误

B.0

C.1

D.运行成功,但不输出

点击查看答案
第8题
下列代码不能正确编译的原因是什么?class A{public static void main(String args[]){B b=new B();b.x=5;}}class B{private int x;Show(){System.out.println(x);}}

点击查看答案
第9题
下列JApplet使用重写paintCompon6t()方法来绘制图像,请填写正确的代码在横线处。 import java

下列JApplet使用重写paintCompon6t()方法来绘制图像,请填写正确的代码在横线处。 import java.awt.*; import javax.swing.*; public class Test extends JApplet { staic String fileName = "IMG nClick=over(this) title=放大().gif"; public void init() { Container cp = getContentPane(); cp.setLayout(new GridLayout(1,1)); Image i = getImage(getCodeBase(),fileName); MyImagePanel ip=new MyInmagePanel(i); cp.add (ip); } } class MyImagePanel extends JPanel { Image i; public MyImagePanel(Image IMG nClick=over(this) title=放大) { this.i = IMG nClick=over(this) title=放大; } public void paintComponent(Graphics gg) { 【 】; gg.drawImage(i,20,20,this); } }

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