You are creating an application that has a form with a text entry field used to enter a persons age. Which of the following is appropriate for capturing this information.
1) Use the Text field of a TextField and parse the result using Integer
2) Use the getInteger method of the TextField
3) Use the getText method of a TextBox and parse the result using the getInt method of Integer class
4) Use the getText method of a TextField and use the parseInt method of the Integer class
Answer 4: Use the getText method of a Textfield and use the parseInt method of the Integer class
Here is an example of how you might do this
Integer.parseInt(txtInputValue.getText());
I'm not sure that a question on this actually will come up in the exam but it is a very useful thing to know in the real world.
No comments:
Post a Comment