linkedin-skill-assessments-quizzes

Android

Q1. To add features, components, and permissions to your Android app, which file needs to be edited?

Q2. Which XML attribute should be used to make an Image View accessible?

Q3. You launch your app, and when you navigate to a new screen it crashes, Which action will NOT help you diagnose the issue?

Q4. Why might push notifications stop working?

Q5. What is correct set of classes needed to implement a RecyclerView of items that displays a list of widgets vertically?

      RecycleView
      RecyclerView.Adapter
      RecyclerView.ViewHolder<T extends BaseViewHolder>
      LinearLayoutManager
      RecycleView
      RecyclerView.Adapter
      RecyclerView.ViewHolder
      LinearLayoutManager
      RecycleView
      RecyclerView.Adapter<VH extends ViewHolder>
      RecyclerView.ViewHolder
      LinearLayoutManager

Q6. The Android system kills process when it needs to free up memory. The likelihood of the system killing a given process depends on the state of the process and the activity at the time. With combination of process and activity state is most likely to be killed?

Q7. You have created a NextActivity class that relies on a string containing some data that pass inside the intent Which code snippet allows you to launch your activity?

        Intent(this, NextActivity::class.java).also { intent ->
            startActivity(intent)
        }
        Intent(this, NextActivity::class.java).apply {
            put(EXTRA_NEXT, "some data")
        }.also { intent ->
            activityStart(intent)
        }
        Intent(this, NextActivity::class.java).apply {
            putExtra(EXTRA_NEXT, "some data")
        }.also { intent ->
            startActivity(intent)
        }
        Intent(this, NextActivity::class.java).apply {
            put(EXTRA_NEXT, "some data")
        }.also { intent ->
            activityStart(intent)
        }

Q8. You want to include about and setting modules in your project. Which files accurately reflects their inclusion?

Q9. What is the benifit of using @VisibleForTesting annotation?

Q10. How would you specify in your build.gradle file that your app required at least API level 21 to run, but that it can be tested on API level 28?

      defaultConfig {
        ...
        minApiVersion 21
        targetApiVersion 28
      }
      defaultConfig {
        ...
        targetSdkVersion 21
        testSdkVersion 28
      }
      defaultConfig {
        ...
        minSdkVersion 21
        testApiVersion 28
      }
      defaultConfig {
        ...
      minSdkVersion 21
        targetSdkVersion 28
      }

Q11. When will an activity’s onActivityResult()be called?

Q12. You need to remove an Event based on it;s id from your API, Which code snippet defines that request in Retrofit?

Q13. When would you use a product flavour in your build setup?

Q14. Given the fragment below, how would you get access to a TextView with an ID of text_home contained in the layout file of a Fragment class?

    private lateinit var textView: TextView
    override fun onCreateView(...): View? {
        val root = inflator.inflator(R>layout.fragment_home, container, false)
        textView = ??
        return root
    }

Q15. Why do you use the AndroidJUnitRunner when running UI tests?

Q16. What allows you to properly restore a user’s state when an activity is restarted?

Q17. Given the definition below. how would you get access a TextView with an ID of text_home contained in thr layout file of a Fragment class?

Q18. IF the main thread is blocked for too long, the system displays the___dialog?

Q19. How would you retrieve the value of a user’s email from SharedPreferences while ensuring that the returned value is not null?

Explanation: In Method “getDefaultSharedPrefarances(this).getString()” Second parameter is passed so that it can be returned, in case key doesn’t exist. So we need to pass an empty string to be returned in case key doesn’t exist.

Q20. Why is it problematic to define sizes using pixels on Android?

Q21. You need to get a list of devices that are attached to your computer with USB debugging enable. Which command would execute using the Android Debug Bridge?

Q22. Which drawable definition allows you to achieve the shape below?

img

    xml
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval">
        <stroke
            android:width="4dp"
	    android:color="@android:color/white" />
	<solid android:color="@android:color/black" />
    </shape>
    xml
    <oval xmlns:android="http://schemas.android.com/apk/res/android">
        <stroke android:width="4dp" android:color="@android:color/black"/>
        <solid android:color="@android:color/white"/>
    </oval>
    xml
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval">
        <stroke
            android:width="4dp"
            android:color="@android:color/black" />
        <solid android:color="@android:color/white" />
    </shape>
    xml
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval">
        <stroke
            android:width="4dp"
            android:color="@android:color/white" />
        <solid android:color="@android:color/white" />
    </shape>

Q23. To persist a small collection of key-value data, what should you use?

Q24. You need to retrieve a list of photos from an API. Which code snippet defines an HTML GET request in Retrofit?

Q25. Given the test class below, which code snippet would be a correct assertion?

Q26. What tag should you use to add a reusable view component to a layout file?

Q27. You want to provide a different drawable for devices that are in landscape mode and whose language is set to French. which directory is named correctly?

Q28. Why might you need to include the following permission to your app?

android.permission.ACCESS_NETWORK_STATE

Q29. Which image best corresponds to the following LinearLayout?

    xml
    <LinearLayout
        android:layout_width="match_parent"
	android:layout_height="match_parent"
	android:orientation="horizontal"
	android:gravity="center">
	<Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button" />
	<Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button" />
        </LinearLayout>

Q30. You want to open the default Dialer app on a device. What is wrong with this code?

val dialerIntent = Intent()
val et = findViewById(R.id.some_edit_text)
dialerIntent.action = Intent.ACTION_DIAL
dialerIntent.data = Uri.parse("tel:" + et.getText()?.toString())
startActivity(dialerIntent)

Q31. When should you store files in the /assets directory?

Q32. You want to allow users to take pictures in your app. Which is not an advantage of creating an appropriate intent, instead of requesting the camera permission directly?

Q33. When would you use the ActivityCompat.shouldShowRequestPermissionRationale() function?

Q34. You would like to enable analytics tracking only in release builds. How can you create a new field in the generated BuildConfig class to store that value?

buildTypes {
	debug {
		buildConfig 'boolean', 'ENABLE_ANALYTICS', 'false'
	}
	release {
		buildConfig 'boolean', 'ENABLE_ANALYTICS', 'true'
	}
}
buildTypes {
	debug {
		buildConfig 'String', 'ENABLE_ANALYTICS', 'false'
	}
	release {
		buildConfig 'String', 'ENABLE_ANALYTICS', 'true'
	}
}
buildTypes {
	debug {
		buildConfigField 'boolean', 'ENABLE_ANALYTICS', 'false'
	}
	release {
		buildConfigField 'boolean', 'ENABLE_ANALYTICS', 'true'
	}
}
buildTypes {
	debug {
		buildConfigField 'boolean', 'ENABLE_ANALYTICS', 'true'
	}
	release {
		buildConfigField 'boolean', 'ENABLE_ANALYTICS', 'false'
	}
}

Q35. To optimize your APK size, what image codec should you use?

Q36. You have built code to make a network call and tested that it works in your development environment. However, when you publish it to the Play console, the networking call fails to work. What will not help you troubleshoot this issue?

Q37. Which code snippet would achieve the layout displayed below?

img

xml
    <androidx.constraintlayout.widget.ConstraintLayout
	...>

	<TextView
		android:id="@+id/text_dashboard"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:layout_marginTop="16dp"
		android:padding="8dp"
		android:textAlignment="center"
		android:text="Dashboard"
		app:layout_constraintEnd_toEndOf="parent"
		app:layout_constraintStart_toStartOf="parent"
		app:layout_constraintTop_toTopOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>
xml
    <androidx.constraintlayout.widget.ConstraintLayout
	...>

	<TextView
		android:id="@+id/text_dashboard"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:layout_marginStart="8dp"
		android:layout_marginEnd="8dp"
		android:textAlignment="center"
		android:text="Dashboard"
		app:layout_constraintEnd_toEndOf="parent"
		app:layout_constraintStart_toStartOf="parent"
		app:layout_constraintTop_toTopOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>
xml
    <androidx.constraintlayout.widget.ConstraintLayout
	...>

	<TextView
		android:id="@+id/text_dashboard"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:layout_marginStart="8dp"
		android:layout_marginTop="16dp"
		android:layout_marginEnd="8dp"
		android:padding="8dp"
		android:textAlignment="center"
		android:text="Dashboard"
		app:layout_constraintEnd_toEndOf="parent"
		app:layout_constraintStart_toStartOf="parent"
		app:layout_constraintTop_toTopOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>
xml
    <androidx.constraintlayout.widget.ConstraintLayout
	...>

	<TextView
		android:id="@+id/text_dashboard"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:layout_marginStart="8dp"
		android:layout_marginTop="16dp"
		android:layout_marginEnd="8dp"
		android:padding="8dp"
		android:text="Dashboard"
		app:layout_constraintEnd_toEndOf="parent"
		app:layout_constraintStart_toStartOf="parent"
	/>

</androidx.constraintlayout.widget.ConstraintLayout>

Q38. Which source set is _not_ available to you by default when Android Studio creates a new project?

Q39. Which definition will prevent other apps from accessing your Activity class via an intent?

xml
	<activity android:name=".ExampleActivity" />
xml
	<activity android:name=".ExampleActivity">
		<intent-filter>
			<action android:name="android.intent.action.SEND" />
		</intent-filter>
	</activity>
xml
	<activity android:name=".ExampleActivity">
		<intent-filter>
			<action android:name="android.intent.action.MAIN" />
			<category android:name="android.intent.category.LAUNCHER" />
		</intent-filter>
	</activity>
xml
	<activity android:name=".ExampleActivity">
		<intent-filter>
			<action android:name="android.intent.action.VIEW" />
		</intent-filter>
	</activity>

Explanation: Intent filters are used to make activities accessible to other apps using intents. So we have to choose option which have no intent filter to make sure it is not accessible by intent

Q40. To preserve on-device memory, how might you determine that the user’s device has limited storage capabilities?

Q41. What is _not_ a good way to reuse Android code?

Q42. Which layout is best for large, complex hierarchies?

Q43. You need to upgrade to the latest version of the Android Gradle plugin. Which file should you modify?

Q44. Why do developers often put app initialization code in the Application class?

Q45. What folder should you use for your app’s launcher icons?

Q46. Which drawable definition allows you to achieve the shape below?

img

xml
	<shape xmlns:android-"http://schemas.android.com/apk/res/android"
	    android:shape-"oval">
	    <gradient
               android:startColor-"@android:color/white"
               android:endColor-"@android:color/black"
               android:angle-"45"/>
	</shape>
xml
	<rectangle xmlns:android-"http://schemas.android.com/apk/res/android">
	   <gradient
	      android:startColor-"@android:color/white"
	      android:endColor-"android:color/black"
	      android:angle-"135"/>
	</rectangle>
xml
	<shape xmlns:android-"http://schemas.android.com/apk/res/android"
	   android:shape-"rectangle">
	   <gradient
	      android:startColor-"@android:color/white"
	      android:endColor-"@android:color/black"
	      android:angle-"135"/>
	</shape>
xml
	<shape xmlns:android-"http://schemas.android.com/apk/res/android"
	   android:shape-"rectangle">
	   <gradient
	      android:startColor-"@android:color/white"
	      android:endColor-"@android:color/black"
	      android:angle-"98"/>
	</shape>

Q47. Given the ConstraintLayout below, which statement is true?

img

Q48. Given this code snippey from a build.gradle file, which choice is not a possible build variant?

android {
    ...
    defaultConfig{...}

    buildTypes{
    debug{...}
    releasae{...}
}

  flavorDimensions "environment"
  productFlavors {
     producation {...}
     staging {...}
  }
}

Q49. What is not good way to reuse Android code?

Q50. When should you use the androidTest directory to store your test classes?

Q51. What is the benifit of using the @VisibleForTesting annotation?

Q52. Given an APK named app-internal-debug.apk produced from the build process, which statement is likely to be true?

Q53. When attempting to build your project, what might the following error indicate?

Conversion to Dalvik format filed: Unable to execute dex: method ID not in [0, 0xffff]: 65536

Q54. Which statement, in build.gradle file, correctly denotes that the corresponding module is an Android library module?

Q55. Given the following dimens.xml file, how would you define an ImageView with medium spacing at the bottom?

<?xml version=1.0 encoding="utf-8"?>
<resources>
    <dimen name="spacing_medium">8dp</dimen>
    <dimen name="spacing_large">12dp</dimen>
</resources>
<ImageView
   android:id=@+id/image_map_pin"
   android:layout_width="wrap_content"
   android:layout_heignt="wrap_content"
   android:src=@drawable/map_pin />
   android:id=@+id/image_map_pin"
   android:layout_width="wrap_content"
   android:layout_heignt="wrap_content"
   androi:layout_botttom="@dimen/spacing_medium"
   android:src=@drawable/map_pin />
<ImageView
   android:id=@+id/image_map_pin"
   android:layout_width="wrap_content"
   android:layout_heignt="wrap_content"
   android:layout_marginBottom="@resources/spacing_medium"
   android:src=@drawable/map_pin />
<ImageView
   android:id=@+id/image_map_pin"
   android:layout_width="wrap_content"
   android:layout_heignt="wrap_content"
   android:layout_marginBottom="@dimen/spacing_medium"
   android:src=@drawable/map_pin />

Q56. what is not a benefit of externalizing app resources such as image and string from a code?

Q57. What is the chief purpose of line five in this code snippet?

override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_post_create)

	if (savedInstanceState != null) return

	val fragment = CreatePostFragment()
		supportFragmentManager
		.beginTransaction()
		.add(R.id. fragment_container, fragment)
		.commit()

}