80.9k views
5 votes
Given an EditText widget named usernameEditText, which statement gets the string that's stored in that widget?

A. String text = usernameEditText.getText().toString();
B. String text = usernameEditText.getString();
C. String text = usernameEditText.value();
D. String text = usernameEditText.getTextValue();

User Norrisa
by
7.5k points

1 Answer

1 vote

Final answer:

The correct statement to get the string stored in an EditText widget named usernameEditText is option A: String text = usernameEditText.getText().toString();

Step-by-step explanation:

The correct statement to get the string stored in an EditText widget named usernameEditText is option A: String text = usernameEditText.getText().toString();

This statement calls the getText() method on the usernameEditText object to retrieve the input text, and then uses the toString() method to convert it to a string. The resulting string is stored in the variable text.

Option B is incorrect because there is no getString() method for EditText widgets. Option C is also incorrect as there is no value() method. Option D is also incorrect as there is no getTextValue() method.

User Neo Vijay
by
7.3k points