It will display 15 on the devices screen 

, 2.

The code will not compile


, 3.

The code will compile but will throw a runtime exception


, 4.

It will not display anything


">
MCQs > IT & Programming > J2ME - Java Platform Micro Edition >

What will happen on attempting to compile and run the following code?

public class ERMidlet extends MIDlet implements CommandListener, Runnable

{

        private Display mDisplay;

        private Form myForm;

        private Command exitCommand;

        private StringItem myString;

        ERMidlet()

        {

                myForm = new Form("Expert Rating Exam");

                exitCommand = new Command("Exit",Command.EXIT, 0);

                myString = new StringItem("15");

                myForm.append(myString);

                myForm.addCommand(exitCommand);

                myForm.setCommandListener(this);

        }

        public void startApp()

        {

                mDisplay = Display.getDisplay(this);

                mDisplay.setCurrent(myForm);

        }

        public void commandAction (Command c, Displayable s)

        {

                destroyApp(false);

                notifyDestroyed();

        }

        public void run()

        {

        }

        public void pauseApp()

        {

        }

        public void destroyApp(boolean unconditional)

        {

        }

}

J2ME - Java Platform Micro Edition MCQs

What will happen on attempting to compile and run the following code?

public class ERMidlet extends MIDlet implements CommandListener, Runnable

{

        private Display mDisplay;

        private Form myForm;

        private Command exitCommand;

        private StringItem myString;

        ERMidlet()

        {

                myForm = new Form("Expert Rating Exam");

                exitCommand = new Command("Exit",Command.EXIT, 0);

                myString = new StringItem("15");

                myForm.append(myString);

                myForm.addCommand(exitCommand);

                myForm.setCommandListener(this);

        }

        public void startApp()

        {

                mDisplay = Display.getDisplay(this);

                mDisplay.setCurrent(myForm);

        }

        public void commandAction (Command c, Displayable s)

        {

                destroyApp(false);

                notifyDestroyed();

        }

        public void run()

        {

        }

        public void pauseApp()

        {

        }

        public void destroyApp(boolean unconditional)

        {

        }

}

Answer

Correct Answer:

It will display 15 on the devices screen 

Explanation:

Note: This Question is unanswered, help us to find answer for this one

J2ME - Java Platform Micro Edition Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

J2ME - Java Platform Micro Edition Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it