Skip to content

Testing II Quiz :Engineering Maintainable Android Apps (Android App Development Specialization) Answers 2025

Question 1 – Reasons to write tests

✔️ to help make sure that changes to code do not break existing functionality
❌ to make apps run faster by reducing binary sizes
❌ to measure how effective software developers are
✔️ to ensure that new functionality operates as expected


Question 2 – True statements when building a new app

✔️ Finding the right design may be an iterative process.
❌ There is exactly one way to implement it.
✔️ Measuring the impact of changes is critical.
❌ There is exactly one way to design it.


Question 3 – What is a unit test

❌ a test that isolates multiple components
❌ a test of a single user interface element
❌ a test that measures performance
❌ a measurement of test coverage
✔️ a test that isolates a specific component


Question 4 – Java framework used for unit tests

❌ Dagger
❌ Retrofit
❌ Apache Commons
✔️ JUnit
❌ Android


Question 5 – Why unit tests must run quickly

✔️ minimize time developers wait for feedback
❌ avoid blocking main thread
❌ minimize emulator startup time
❌ ensure UI isn’t slowed
✔️ minimize developer mistakes


Question 6 – Valid JUnit test

Only one is valid:

@Unit public void ensureTrue() { ... } (invalid annotation)
@Test public void test() { ensure.that(true); } (invalid call)
@Unit public void test() throws Exception { ... } (invalid annotation)
public void test() { ensureTrue(true); } (no @Test annotation)
✔️ @Test public void ensureTrue() { assertEquals(true,true); }


Question 7 – NOT appropriate ways to set up MyObject

Correct choices = NOT appropriate

1️⃣ ❌ Not appropriate — initializing inside test method
5️⃣ ❌ Not appropriate — inline initialization but missing a test for size

Correct answers:
✔️ Option 1
✔️ Option 5


Question 8 – Valid tests for method throwing checked exception

❌ Calling dangerous() without handling exception
✔️ try–catch with assertion
❌ using @Unit annotation
✔️ @Test with throws Exception
✔️ try–catch but ignoring exception


Question 9 – Valid uses of code coverage

❌ techniques to test faster
❌ guarantee bug-free
✔️ determine where more testing is needed
❌ evaluate dev team quality
✔️ determine if app has been sufficiently tested


Question 10 – About the constructor call

JUnit creates a new instance of the test class for every @Test method, so:

✔️ The MyObject constructor will be called at least once for each @Test annotation.
❌ Only once before first
❌ Only once before second
❌ Not called → NPE
❌ Needs @Before

Q.No Correct Answer Mark
1 a constructor that makes an implicit call to a constructor in the super class. ✔️
2 Line 54 ✔️
3
4
5
6
7
8
9
10