This course will be retired on July 14, 2025.
- Simple Refactoring: Creating a New Class 5:54
- Creating a New Class 2 objectives
- Simple Refactoring: Using a New Class 6:28
- Simple Refactoring 5 questions
- Dynamically Changing the Background Color 3:51
- Dynamically Changing the Background Color 1 objective
- Adding More Colors 3:43
- Using the New Colors 3:42
- Adding Colors 1 objective
- Adding an App Icon 4:50
- Adding an App Icon 3 questions
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’s missing an important semicolon.
-
C
It uses the incorrect syntax for the onClick() method.
-
D
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.