ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 14 - Associate Android Developer discussion

Report
Export

For example, we have a BufferedReader reader, associated with the json file through InputStreamReader. To get a file data we can do this:

A.
var line: String?try {while (reader.readLine().also { line = it } != null) {builder.append(line)}val json = JSONObject(builder.toString()) return json} catch (exception: IOException) { exception.printStackTrace() } catch (exception: JSONException) { exception.printStackTrace()}
Answers
A.
var line: String?try {while (reader.readLine().also { line = it } != null) {builder.append(line)}val json = JSONObject(builder.toString()) return json} catch (exception: IOException) { exception.printStackTrace() } catch (exception: JSONException) { exception.printStackTrace()}
B.
var line: JSONObject ? try {while (reader.readJSONObject ().also { line = it } != null) { builder.append(line)}val json = JSONObject(builder.toString()) return json} catch (exception: IOException) { exception.printStackTrace() } catch (exception: JSONException) { exception.printStackTrace()}
Answers
B.
var line: JSONObject ? try {while (reader.readJSONObject ().also { line = it } != null) { builder.append(line)}val json = JSONObject(builder.toString()) return json} catch (exception: IOException) { exception.printStackTrace() } catch (exception: JSONException) { exception.printStackTrace()}
C.
var line: String? try {while (reader.readLine().also { line = it } != null) { builder.append(line)}val json = JSONObject(builder.toString()) return json} catch (exception: RuntimeException) { exception.printStackTrace()} catch (exception: ArrayIndexOutOfBoundsException) { exception.printStackTrace()}
Answers
C.
var line: String? try {while (reader.readLine().also { line = it } != null) { builder.append(line)}val json = JSONObject(builder.toString()) return json} catch (exception: RuntimeException) { exception.printStackTrace()} catch (exception: ArrayIndexOutOfBoundsException) { exception.printStackTrace()}
Suggested answer: A
asked 18/09/2024
DIEGO MORENO
41 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first