ASSOCIATE-ANDROID-DEVELOPER Web TestEngine demo

Exit VCEDump ASSOCIATE-ANDROID-DEVELOPER Associate Android Developer (Kotlin and Java)
Question 4 of 20
0% complete
Q4 Single choice

An example. In our ViewModelFactory (that implements ViewModelProvider.Factory) we have an instance of our Repository, named mRepository. Our ViewModel has such constructor:

public MyViewModel(MyRepository myRepository)...
Next, in our ViewModelFactory create ViewModel method (overriden) looks like this:
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
try {
//MISSED RETURN VALUE HERE
}
catch (InstantiationException | IllegalAccessException |
NoSuchMethodException | InvocationTargetException e) {
throw new RuntimeException("Cannot create an instance of " + modelClass, e);
}
}

What should we write instead of "//MISSED RETURN VALUE HERE"?

Sign in to mark questions

Sign in to save marked questions and return to this demo.

Sign in