NIIT认证J2ME考试真题

2016-10-26 00:00:00嘉辉 NIIT认证

  1) 下面的哪个包包含由MIDP支持的GUI组件?P3.5

  1. javax.microedition.MIDlet 2. javax.microedition.io

  3. javax.microedition.rms 4. javax.microedition.lcdui

  2) 思考下面的代码:

  import javax.microedition.midlet.*;

  import javax.microedition.lcdui.*;

  public class Hello extends MIDlet

  {

  private Display Exhibit;

  private Form show;

  public Hello()

  {

  Exhibit = Display.getDisplay(this);

  show = new Form("Name");

  }

  public void startApp() throws MIDletStateChangeException

  {

  disp.setCurrent(show);

  }

  public void pauseApp()

  {

  }

  public void destroyApp(boolean unconditional)

  {

  }

  }

  下面的哪个代码段应该被增加到上述的代码中来创建一个字符串项并将它显示在屏幕上?P2.8-2.9

  1. StringItem strIt = new StringItem(" ", "Msg"); StringItem.append(strIt);

  2. StringItem strIt = new StringItem(" ", "Msg"); show.append(strIt);

  3. show = new StringItem(" ", "Msg"); StringItem.append(strIt);

  4. StringItem strIt = new StringItem(" ", "Msg"); StringItem.append(show);

  3) 你正在为一个银行程序开发一个MIDlet。当客户向银行发送一个请求时,一个进程指示将一直显示,直到请求被处理完为止。进程指示应该被嵌入到form组件中。下面 的哪个方法可以在设备屏幕上显示进程指示?P4.16

  1. public void showGauge() { Form form = new Form(“Gauge”); Gauge gauge = new Gauge (“Progress”, false, 100, 0); form.append (gauge); Display display = Display.getDisplay(this); display.setCurrent(form); }

  2. public void showGauge() { Gauge gauge = new Gauge (“Progress”, false, 100, 0); Display display = Display.getDisplay(this); display.setCurrent(gauge); }

  3. public void showGauge() { Form form = new Form(“Gauge”); Gauge gauge = new Gauge (“Progress”, false, 100, 0); form.append (gauge); Display.setCurrent(form); }

  4. public void showGauge() { Form form = new Form(“Gauge”); Gauge gauge = new Gauge (“Progress”, false, 100, 0); form.append (gauge); Display display = Display.getCurrent(form); display.setCurrent(gauge); }

  4) 在J2ME中,下面的哪个包可以使用网络连接?P3.4

  1. javax.microedition.midlet

  2. javax.microedition.lcdui

  3. javax.microedition.io

  4. java.io

  5) 思考下面的陈述:

  陈述A:标准的J2ME工具包可以解析XML文件。

  标准B:基于XML解释器的事件保存被移动设备解析的整个XML文件。

  关于上面陈述,下面哪项是正确的?P5.20

  1. 陈述A是正确的,陈述B是错误的。 2. 陈述A是错误的,陈述B是正确的。

  3. 两个陈述都是正确的。 4. 两个陈述都是错误的。

  6) 你正在编写连接到Web服务器上运行的一个servlet的MIDlet代码。MIDlet的代码段如下所示:

  public void connhandler()

  {

  HttpConnection con = null;

  display("Obtaining Connection from Server..." );

  try

  {

  con = MyHttpConnection.connect(url, this );

  display("Connecting to the server..." );

  int response = con.getResponseCode();

  if( response == HttpConnection.HTTP_OK )

  {

  StringBuffer text = new StringBuffer();

  // Here's where you read the data.

  // This case expects an integer

  // followed by zero or more

  // strings.

  try

  {

  DataInputStream din = new DataInputStream(con.openInputStream() );

  int n = din.readInt();

  while( n-- > 0 )

  {

  text.append(din.readUTF() );

  text.append( '"n' );

  }

  }

  catch( IOException e )

  {

  }

  done("Your current balance:"n" + text.toString() );

  }

  else

  {

  done("Unexpected return code: " + rc );

  }

  }

  catch( IOException e )

  {

  done( "Exception " + e + " trying to connect." );

  }

  }

  编译MIDlet代码后,你试图不启动Web服务器来连接servlet。根据上面的代码段,程序将会输出什么?P6.17

  1. Unexpected return code: 500

  2. Unexpected return code: 302

  3. Unexpected return code: 303

  4. Exception java.io.IOException trying to connect

  7) 一个文本文件包含几行文本,一个在MIDlet和文本文件之间的连接已经被建立。下面的哪个代码段将打开一个输入连接并每次从这个文本文件中获取一行文本?P5.12

  1. InputStream ins = null; ins = connect.openInputStream(); StringBuffer buffer = new StringBuffer(); int i; while ((i=ins.read())!= -1) { if (i!='"n') { buffer.append(i); } }

  2. InputStream ins = null; ins = connect.openInputStream(); StringBuffer buffer = new StringBuffer(); int i; while ((i=ins.read())!= -1) { if (i!='"n') { buffer.append((char)i); } }

  3. InputStream ins = null; ins = connect.openOutputStream(); StringBuffer buffer = new StringBuffer(); int i; while ((i=ins.read())!= -1) { if (i!='"n') { buffer.append((char)i); } }

  4. InputStream ins = null; ins = connect.openInputStream(); StringBuffer buffer = new StringBuffer(); char i; while ((i=ins.read())!= -1) { if (i!='"n') { buffer.append((char)i); } }

  8) 确定javax.microedition.io包的类。P3.4

  1. Connector 和 ConnectionNotFoundException 2. InputStream 和OutputStream

  3. DataInput 和 DataOutput 4. DataInputStream 和 DataOutputStream

  9) RecordEnumeration接口定义了下面的哪个方法?P7.4

  1. enumerateRecords() 2. getRecord() 3. nextRecord() 4. addRecord()

  10) 代码段如下所示:(19)

  代码段1:

  byte[] ba = new byte[50];

  int nob = rs.getRecord (id, ba, 0);

  代码段2:

  byte[] ba = null;

  ba = rs.getRecord (id);

  代码段3:

  byte[] ba = new byte[50];

  ba = rs.getRecord (id);

  代码段4:

  byte[] ba = null;

  int nob = rs.getRecord (id, ba);

  用下面哪个代码段从记录存储中获取一条特定记录?P7.8

  1. 仅代码段1和代码段3 2. 仅代码段2和代码段4

  3. 代码段2、代码段3和代码段4 4. 代码段1、代码段2和代码段3

  11) SaveMyMoney银行为他们的客户介绍移动银行业务。有一个应用程序使用名为checks.db的记录存储,使客户方便的记录所有提交到银行的单据。你能够使用下面哪段代码获取checks.db中的列举对象?P7.10

  1. public void getEnum() { RecordStore rs; rs = RecordStore.openRecordStore(“checks”, true); rs = RecordStore.enumerateRecords (null, null, false); }

  2. public void getEnum() { RecordEnumeration re; RecordStore rs; rs = RecordStore.openRecordStore(“checks”, true); re = rs.enumerateRecords (null, null, false); }

  3. public void getEnum() { RecordStore rs; rs = RecordStore.openRecordStore(“checks”, true); RecordEnumeration re = RecordEnumeration.enumerateRecords (null, null, false); }

  4. public void getEnum() { RecordEnumeration re; RecordStore rs; rs = RecordStore.openRecordStore(“checks”, true); rs = re.enumerateRecords (null, null, false); }

 1/2    1 2 下一页 尾页

[NIIT认证]相关推荐

[NIIT认证]相关栏目推荐
查看更多
上一篇:NIIT全球情况 下一篇:it行业发展前景