160k views
5 votes
Which statement displays a message on the user interface that says, "Hello"?

A. textView.setText("Hello");
B. editText.displayMessage("Hello");
C. showMessage("Hello");
D. Toast.makeText(context, "Hello", Toast.LENGTH_SHORT).show();

User GSTD
by
7.6k points

1 Answer

6 votes

Final answer:

The correct statement to display the message "Hello" on the user interface of an Android application is D. Toast.makeText(context, "Hello", Toast.LENGTH_SHORT).show(); which creates a brief pop-up notification called a Toast.

Step-by-step explanation:

The question is asking which statement in a given programming language would display a message saying "Hello" on the user interface. Considering the options provided, the correct statement for displaying a message in the user interface of an Android application using a toast is:

D. Toast.makeText(context, "Hello", Toast.LENGTH_SHORT).show();

This line of code creates a small pop-up notification, commonly known as a Toast, that briefly shows the message "Hello" to the user. Options A, B, and C either refer to methods that don't exist or methods that serve different purposes in Android development.

User Sean P
by
7.1k points