J2ME模拟测试题及答案

这些是SUN公司的J2ME测试题,整理了一下,大家做做看能得几分(5分/题),附答案及详解

.Programmer Quiz

Find out how much you know about the J2ME Mobile Information Device Profile (MIDP) with this comprehensive quiz

 

1.     A midlet is a Java class that extends the abstract class:

A). javax.microedition.MIDlet

B).javax.microedition.midlet

C).javax.microedition.midlet.MIDlet

D).javax.microedition.midlet.midlet

 

 

2.       Which one of the following methods of the MIDlet abstract class must be implemented by a midlet:

 

A).initApp, startApp

B).startApp, destroyApp

C).startApp, pauseApp, destroyApp

D).initApp, startApp, pauseApp, destroyApp

 

3.        After compiling your midlet, you must process it with a command to ensure that it is valid before use by the Kilo virtual machine (KVM). What is the name of that command?

 

A).Midp

B).javac-bootclasspath

C).preverify

D).jar

 

4.        A Java Application Descriptor (JAD) file is a text file that is similar to a manifest, except that it is not packaged in a JAR file. Some of the shared attributes that must have identical values are: MIDlet-Name, MIDlet-Version, and MIDlet-Vendor. If any shared attributes are different, then:

A).The ones in the descriptor override those in the manifest

B).The ones in the manifest override those in the descriptor

 

 

5.        When downloading application descriptors (.jad files) from a web server, the web server must return a MIME type of:

 

A).text/vnd.sun.j2me.midp

B).text/vnd.sun.j2me.jad

C).text/vnd.sun.j2me.app-descriptor

D).text/vnd.sun.j2me.midapp

 

 

6.        A midlet suite is a set of midlets that are packed together into a single JAR file. Midlets within the same suite:

 

A).Can share the classes and resources contained in the JAR file

B).Cannot share the classes and resources contained in the JAR file

 

7.        Midlets from different suites:

A).Can interact directly.

B).Cannot interact directly

 

8.        What is the difference between a configuration (such as the CLDC) and a profile (such as the MIDP)?

 

A).a configuration defines the set of class libraries available for a particular domain of devices, and a profile provides I/O and network APIs.

B).a configuration defines a vertical set of classes that a profile can use.

C).a configuration defines a minimum set of class libraries for a wide range of devices, and a profile defines the set of APIs available for a particular family of devices.

D).a profile is the foundation for a configuration.

 

9.        All MIDP implementations are required to support what image format?

A).GIF

B).JPG

C).BMP

D).PNG

 

10.     If a midlet needs to receive high-level events from the implementation, which interface should it implement?

A).ActionListener

B).CommandListener

C).Windows Listener

D).ChoiceListener

 

 

11.     All MIDP GUI classes are contained in what package?

A).javax.microedition.gui

B).javax.microedition.lcd

C).javax.microedition.lcdui

D).javax.microedition.display

 

12.     The MIDP user interface API is a subset of the AWT/ Project Swing libraries.

 

A).True

B).False

 

13.     Which class would you use to write applications to access low-level input events or to issue graphics calls for drawing to the display?

A).Display

B).Command

C).Screen

D).Canvas

 

14.     Which of the following statements is true regarding the Generic Connection framework:

A).The CLDC provides an implementation for the HTTP protocol.

B).All MIDP implementations must provide support for the HTTP protocol.

C).The MIDP provides implementation for datagram and socket connections

D).The Connection interface is part of the java.net package.

 

15.     The heart of the Generic Connection framework is:

 

A).javax.microedition.Connection

B).javax.microedition.Connector

C).javax.microedition.StreamConnection

D).javax.microedition.HttpConnection

 

16.     What is the correct syntax, using the Generic Connection framework, to open an HTTP connection:

 

A).Connection c = Connection.open("http://developer.java.sun.com");

B).Connector c = Connector.open("http://developer.java.sun.com");

C).Connection c = Connector.open("http://developer.java.sun.com");

D).Connector c = Connection.open("http://developer.java.sun.com");

 

17.     The MIDP provides a mechanism for MIDlets to persistently store data in a platform-dependent file and retrieve it later. This mechanism is:

A).Object Serialization

B).JDBC

C).RMS

D).ODBC

 

18.     A Java virtual machine1 (JVM) supporting CLDC has no support for:

A).Floating point numbers

B).Reflection

C).JNI

D).All of the above

 

19.     Which of the following non-exception classes are inherited from the Java 2 Standard Edition 1.3 java.util package by the CLDC:

 

A).Calendar, Date, Enumeration, Hashtable, Stack, Vector

B).Calendar, Date, Enumeration, Hashtable, Random, Stack, Timer, Vector

C).Calendar, Date, Enumeration, Hashtable, Stack, Vector, StringTokenzier

D).All of the java.util classes are inherited

 

20.     Which of the following techniques can be used for wireless session tracking?

 

A).Cookies

B).URL Rewriting

C).Hidden Fields

D).None of the above

 

 

.MIDP Quiz Answers

1.        A midlet is a Java class that extends the abstract class

Answer (C) is correct. At the basic level, a midlet is a Java class that extends the javax.microedition.midlet.MIDlet abstract class. Inheriting from this class and providing implementation for some specific methods makes that Java class a midlet that may run in a midlet application manager.

 

2.        Which of the following methods of the MIDlet abstract class must be implemented by a midlet:

Answer (C) is correct. A midlet extending the MIDlet abstract class must implement the startApp, pauseApp, and destroyApp methods. These methods are analogous to the start, stop, and destroy methods of the Applet class.

 

3.        After compiling your midlet, you must process it with a command to ensure that it is valid before use by the Kilo virtual machine (KVM). What is the name of that command?

Answer (C) is correct. In the J2SE Java virtual machine1, the class verifier is responsible for rejecting invalid class files. A JVM supporting CLDC must be able to reject invalid class files as well, however, the class verification process is expensive and time consuming; therefore, not ideal for small, resource-constrained devices. The KVM designers decided to move most of the verification work off the device and onto the desktop, where the class files are compiled onto a server machine from which applications are being downloaded. This step (off-device class verification) is referred to as preverification and can be done using the preverify command.

 

4.        A Java Application Descriptor (JAD) file is a text file that is similar to a manifest, except that it is not packaged in a JAR file. Some of the shared attributes that must have identical values are: MIDlet-Name, MIDlet-Version, and MIDlet-Vendor. If any shared attributes are different, then:

   Answer (A) is correct. The use of JAD files is optional but recommended. It enables the device to verify things like whether the JAR file is too big for the device, whether a new version of the MIDlet suite is already installed on the device, etc., without actually downloading the JAR file.

 

5.        When downloading application descriptors (.jad files) from a Web server, the Web server must return a MIME type of:

   Answer (C) is correct. The server must return a MIME type of text/vnd.sun.j2me.app-descriptor. For Apache servers, you can enable this by adding the following line to the httpd.conf file: AddType text/vnd.sun.j2me.app-descriptor .jad.

 

6.        A midlet suite is a set of midlets that are packaged together into a single JAR file. Midlets within the same suite

   Answer (A) is correct. Midlet suites are special since midlets in the same suite can share the classes and resources contained in the JAR file. <script type="text"> Editor_Edit_ftbBody_HtmlMode = false; Editor_Edit_ftbBody_BreakMode = 'Paragraph'; Editor_Edit_ftbBody_TabMode = 'InsertSpaces'; Editor_Edit_ftbBody_StartMode = 'DesignMode'; Editor_Edit_ftbBody_DesignModeCss = ''; Editor_Edit_ftbBody_HtmlModeCss = ''; Editor_Edit_ftbBody_ReadOnly = false; Editor_Edit_ftbBody_HideToolbar = true; Editor_Edit_ftbBody_HtmlModeDefaultsToMonoSpaceFont = true; Editor_Edit_ftbBody_UpdateToolbar = true; Editor_Edit_ftbBody_TextDirection = 'LeftToRight'; Editor_Edit_ftbBody_HasFocus = false; </script>

 

7.        Midlets from different suites:

Answer (B) is correct. Midlets from different suites cannot interact directly. A midlet in one suite cannot read from a database created by a midlet in another suite, for example.

 

8.        What is the difference between a configuration (such as the CLDC) and a profile (such as the MIDP)?

Answer (C) is correct. The Connected Limited Device Configuration (CLDC) is a standard, portable, minimum-footprint configuration for small, resource-constrained mobile devices, and is the foundation for the MID Profile. A configuration defines the minimum set of class libraries available for a range of devices, and a profile defines the set of APIs available for a particular family of devices. The MID Profile provides a standard platform for small, resource-constrained, wireless-connected mobile information devices. So, you can think of the CLDC as a horizontal set of classes, and the MID Profile (MIDP), which is built on top of CLDC, as a vertical set of classes. This means that MIDP has access to all the classes provided by the CLDC.

 

9.        All MIDP implementations are required to support what image format?

Answer (D) is correct. ALL MIDP implementations are required to support images stored in PNG format. PNG is a file format for the portable well-compressed storage of raster images. It provides a patent-free replacement for GIF.

 

10.     If a midlet needs to receive high-level events from the implementation, which interface should it implement?

Answer (B) is correct. Handling events in the high-level API is based on a listener model. Screen and Canvas objects can have listeners for commands. For an object to be a listener, it must implement the CommandListener interface. You add commands to a displayable object with the addCommand method, and register a listener with the setCommandListener method. The CommandListener interface has one method that a listener must implement: commandAction.

 

11.     All MIDP GUI classes are contained in what package?

Answer (C) is correct. All MIDP GUI classes are in the lcdui package. To use the GUI classes, your MIDlets must import this package: import javax.microedition.lcdui.

 

12.     The MIDP user interface API is a subset of the AWT/Swing libraries.

Answer (B) is correct. The MIDP User Interface API is not a subset of the AWT/Swing libraries. J2ME provides a set of simple UI components. Programming with these components is easy in comparison with the J2SE AWT and Project Swing libraries because the MIDP GUI API is simpler.

 

13.     Which class would you use to write applications to access low-level input events or to issue graphics calls for drawing to the display?

Answer (D) is correct. The Canvas class, which is a subclass of Displayable, allows the application to register a listener for commands, but it requires applications to subclass it first. It is designed for applications that need precise placement and control of graphic elements and access to low-level input events. It gives the application full control over what is being drawn on the display. However, it is important to note that MIDlets that access the low-level API are not guaranteed to be portable because the Canvas class, and other low-level APIs, provide mechanisms to access details that are specific to a particular device.

 

14.     Which of the following statements is true regarding the Generic Connection framework:

Answer (B) is correct. All MIDP implementations must provide support for the HTTP protocol. It is up to the implementors to support datagram connections. It is recommended, however, to use only protocols supported by MIDP (for example, HTTP) because this will allow the application to be portable across all mobile information devices.

 

15.     The heart of the Generic Connection framework is:

Answer (B) is correct. The Connector class is the heart of the Generic Connection framework, which is used by CLDC-based applications to obtain a Connection object.

 

16.     What is the correct syntax, using the Generic Connection framework, to open an HTTP connection:

Answer (C) is correct. An HTTP connection is opened using: Connection c = Connector.open("http://developer.java.sun.com"). The Connection interface and its sub-interfaces make performing communication easy without having to worry about implementation details.

 

17.     The MIDP provides a mechanism for MIDlets to persistently store data in a platform-dependent file and retrieve it later. This mechanism is:

Answer (C) is correct. The mechanism is a simple record-oriented database called the Record Management System (RMS). A MIDP database (or a record store) consists of a collection of records that remain persistent after the MIDlet exits. When you invoke the MIDlet again, it can retrieve data from the persistent record store. To use the RMS, import the javax.microedition.rms package.

 

18.     A Java virtual machine supporting CLDC has no support for:

Answer (D) is correct. A number of features have been eliminated from a JVM supporting CLDC, either because they are too expensive to implement or their presence would have imposed security problems. Some of the features that have been eliminated are:

  • Floating point numbers: the CLDC does not support floating point numbers and therefore no CLDC-based application can use any floating point numbers and types such as float or double. This is mainly because CLDC target devices do not have hardware floating point support.
  • Reflection: no reflection features are supported, and therefore there is no support for RMI or object serialization.
  • Java Native Interface (JNI): a JVM supporting CLDC does not implement the Java Native Interface (JNI) for security reasons, and implementing JNI is considered expensive given the memory constraints of the CLDC target devices.

 

19.     Which of the following non-exception classes are inherited from the J2SE 1.3 java.util package by the CLDC:

Answer (B) is correct. The inherited classes from the J2SE java.util package are: Calendar, Date, Enumeration, Hashtable, Random, Stack, Timer, Vector.

 

20.     Which of the following techniques can be used for wireless session tracking?

Answer (B) is correct. To keep track of wireless session, the URL Rewriting technique is ideal for clients that do not support cookies or have cookies disabled. In this technique, the session information is encoded into URLs that the server generates.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值