Quiz: Android
Android questions from real interviews as a quiz, with an explanation for every option.
Try it: 5 questions
Loading…
Sample questions
In which situations is it justified to optimize data parsing? Select all that apply.
- When parsing runs in real time or affects the responsiveness of the UI.
- Before measuring anything, simply because the parser code looks complicated.
- When processing a large volume of data and parsing has become a performance bottleneck.
- When parsing a small static file once at application startup.
- On a resource-constrained device where memory or processing time matters.
What is the usual way to upload an image file to a server with Retrofit?
- Put the image in a request header using
@Header. - Serialize the file as JSON and send it with
@Bodywithout multipart encoding. - Pass the file as a regular
@Queryparameter in the request URL. - Send it as a
multipart/form-datapart using@MultipartandMultipartBody.Part.
- Put the image in a request header using
In MVI, if
Stateis represented by an immutable object, how is one of its properties usually updated?- Change the value only in the UI without updating state
- Create a new ViewModel for every property change
- Change the property on the existing state object
- Create a new state object with the changed value and publish it
Which three practices can improve scrolling performance for long lists in Jetpack Compose?
- Use
LazyColumnorLazyRowto create items as needed. - Prefer
Columnfor long lists because it creates only the visible items. - Use
rememberfor every value so it is recalculated on every scroll. - Provide a unique, stable
keyfor each list item. - Move expensive work out of composable functions and cache values that can be reused.
- Use
How does a memory cache in Android typically handle a data request?
- It first looks up the key in the cache; on a miss, it fetches the data from the source and may store it for later requests.
- It refreshes every entry on each request so that all data stays up to date.
- It always loads data from the original source and uses the cache only to delete data.
- It stores all data permanently on disk and returns it even after the app restarts.
Which statements about Kotlin
sealed classare correct? Select three.- Adding a subclass automatically serializes it for network requests.
- A restricted hierarchy makes it possible to handle every case without requiring an
elsebranch in an exhaustivewhen. - Direct subclasses can be declared in any package and module without restrictions.
- The hierarchy is useful for modeling a finite set of states, events, or API results.
- The compiler knows the permitted direct subclasses and can check whether a
whenis exhaustive.
What problems can arise when using non-string objects as keys in a Java
HashMap? Select all that apply.- Incorrect
equals()orhashCode()implementations can break key lookup and comparison. - An expensive
hashCode()implementation can slow down map operations. - Every key must implement
Serializable. HashMapcompares non-string keys by reference only and ignoresequals().- Changing a key after inserting it can make its entry impossible to find.
- Incorrect
Which mechanism lets
AtomicInteger.incrementAndGet()update its value atomically when threads compete?- Compare-and-set (CAS), retrying if a conflict is detected
- Copying the value into a new object before each update
- An automatic lock on the whole object for every access
- Ordinary
volatile, which makes any update atomic
Which main phases does UI go through in Jetpack Compose when a frame is produced?
- View creation → measurement → event handling
- Composition → measurement and placement → drawing
- State reading → model update → drawing
- Composition → recomposition → state remembering
In Java, a
Threadobject has been created. How do you run its code on a separate thread?- Call
execute()on theThreadobject. - Call
start()on theThreadobject. - Create a
Runnableobject and callstart()on it. - Call
run()on theThreadobject.
- Call