CertyRush
Đang tải...
C CertyRush
Câu hỏi free preview

Câu 15: Associate Android Developer

An example. In our ViewModelFactory (that implements ViewModelProvider.Factory) we have an instance of our Repository, named mRepository. OurViewModel has such constructor:class MyViewModel(private val mRepository: MyRepository) : ViewModel() ...Next, in our ViewModelFactory create ViewModel method (overriden) looks l…

Nội dung câu hỏi

An example. In our ViewModelFactory (that implements ViewModelProvider.Factory) we have an instance of our Repository, named mRepository. OurViewModel has such constructor:class MyViewModel(private val mRepository: MyRepository) : ViewModel() ...Next, in our ViewModelFactory create ViewModel method (overriden) looks like this: override fun create(modelClass: Class ): T { return try {//MISSED RETURN VALUE HERE"} catch (e: InstantiationException) {throw RuntimeException("Cannot create an instance of $modelClass", e)} catch (e: IllegalAccessException) {throw RuntimeException("Cannot create an instance of $modelClass", e)} catch (e: NoSuchMethodException) {throw RuntimeException("Cannot create an instance of $modelClass", e)} catch (e: InvocationTargetException) {throw RuntimeException("Cannot create an instance of $modelClass", e)}}What should we write instead of "//MISSED RETURN VALUE HERE"?

Các lựa chọn

Đáp án được giữ gọn theo nhãn A, B, C, D trong phần bình chọn tương tác.

  1. A. modelClass.getConstructor() .newInstance(mRepository)
  2. B. modelClass.getConstructor(MyRepository::class.java) .newInstance()
  3. C. modelClass.getConstructor(MyRepository::class.java) .newInstance(mRepository) — đáp án hiện tại

Cộng đồng

0 bình luận công khai. Tên thành viên được ẩn một phần.

Chưa có bình luận. Mở giao diện tương tác để bắt đầu thảo luận.

Câu hỏi liền kề