This course will be retired on July 14, 2025.
Quiz Question 1 of 5
What’s wrong with the following code (even though it might never crash)?
public void onClick(View v) { FactBook factBook = new FactBook(); String fact = factBook.getFact(); factTextView.setText(fact); }
Choose the correct answer below:
-
A
The getFact() method cannot be called after the FactBook variable is instantiated.
-
B
It creates a FactBook object every time the user taps the button, which takes up memory and processing power, and could eventually crash the app.
-
C
It’s missing an important semicolon.
-
D
It uses the incorrect syntax for the onClick() method.