Android & Kotlin Sheet

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 23

Kotlin Exercise

1.  Find ASCII value of a character.


2. Write a function iseven that accepts any integer values, then returns
true if the value is even, or false if the value is odd.
a. Write a main program that Reads even numbers from user until
the user enters an odd number (Hint: use the function iseven
to determine whether the number is even or not),
b. Calculates and prints the total sum of even numbers.
3. Write a program that reads a character from user then Check if it is
an alphabet or not using when.
4. Write a program that reads a set of numbers from user then
calculate sum and average until user enters 0.
5. Write a program that reads two numbers from user then Swap two
numbers using temporary variable.
Android Questions
Q1. Android is an open source, Linux-based software stack.
a. True
b. False
Answer: a
--------------------------------------------------------------------
Q2- Which of the following choices is the main role of the button which is
illustrated in the red rectangle over the Android Studio tool bar?

a- Run button.
b. Debug button.
c- Apply changes button.
d- ADV manager button.

Answer: c

Q3. Each Android application runs in its own process and with its own
instance of ART on devices running Android version 8.0 (API Level 26) or
higher.
a. True
b. False
Answer: a
Q4-Which of the following choices is the main role of the Preview button
which is illustrated in the red circle of the vertical Android Studio tool
bar?

a- It shows the activity layout in text (XML) and design mode at the
same time.
b- It shows the activity layout in print review.
c- It shows the Java or Kotlin code of an activity.
d- It shows the activity blue print preview mode.
Answer: a
--------------------------------------------------------------------------------
Q5. The Android library code is organized in such a way that it can be
used by multiple Android applications.
a. True
b. False

Answer: a
Q6- The following image shows part of the content inside file
activity_main.xml in an Android application: Which of the following
options is correct?

a- The app user can select one radio button only at a time.
b- The app user can select the two radio buttons at the same time.
c- The only purpose of RadioGroup tag is adding a group of colors to
the inside of the radio buttons.
d- This is not an XML code; it is a Kotlin code.
Answer: a
----------------------------------------------------------------------------
Q7- android.view : This library contains the basic classes used for
developing graphical user interface and for handling the user’s
interaction with the user interface
a.True
b. False
Answer: a
Q8- Fill in the blank space in the following sentence with the correct
choice: The …………………… arranges widgets in positions relative to each
other.
a- RelativeLayout
b- Linear Layout
c- ConstraintLayout
d- Table Layout
Answer: a
--------------------------------------------------------------------
Q9- android.widget : This library contains (mostly visual) user interface
components such as Button, Spinner, ListView to be used in your
applications.
a. True
b. False
Answer: a
--------------------------------------------------------------------------------
Q10- Fill in the blank space in the following sentence with the correct
choice: The ………………………… is a layout that arranges other views either
horizontally in a single column or vertically in a single row.
a- LinearLayout
b- RelativeLayout
c- ConstraintLayout
d- Frame Layout
Answer: a
Q11. Android content providers are used to manage and share
application data between applications.
a. True
b. False
Answer: a
---------------------------------------------------------------------------
Q12. Which of the following choices is the best answer to fill the empty
space in the following sentence? Adding a new color to the colors.xml file
in Android Studio (/res/values/colors.xml ) helps the app developers to
use this new color as attribute value for the ……………. attribute in all
these app layouts.
a- android:textColor
b- Kotlin:textcolor
c- Java:textcolor
d- color:textformat
Answer: a
--------------------------------------------------------------------
Q13. Views are objects that are drawn on the screen. View is the parent
class of all activity user interface components. Each activity is made up of
a set of views grouped together within a layout.
a. True
b. False

Answer: a
Q14. As an Android developer, to change the font size of a text in Android
layout, you should use attribute “android:textSize”. Which of the
following choices is the recommended syntax to change the font size to
18?
a- android:textSize="18sp"
b- android:textSize="18dp"
c- android:textSize="18point"
d- android:textSize="18sd"
Answer: a
---------------------------------------------------------------------
Q15. Which of the below choices is the best answer to fill the empty space
in the following sentence?
If you want to give all text widgets in an app the same format such as font
color, font size, and font family, you should add the style attribute to the
TextView XML tags in layout file and set the attribute value to the same
style name. You should define that style by adding a new style tag <style
name =”style_name”> inside …………..
a- styles.xml file
b- AndroidManifest.xml file
c- MainActivity.java or MainActivity.kt file
d- activity_main.xml file
Answer: a

Q16. Fill in the blank space in the following sentence with the correct
choice: To configure your style as the theme for all your app activities
(entire app), open AndroidManifest.xml, and set the theme by adding
android:theme=”@style/your_style_name” attribute to the
………………………..
a- <application> tag.
b- <activity>tag.
c- <intent-filter>tag.
d- <manifest>tag.
Answer: a
---------------------------------------------------------------
Q17. Fill in the blank space in the following sentence with the correct
choice: The following image shows the content of an
AndroidManifest.xml file of an Android app. The role of adding the
attributes “android:icon” and “android:roundIcon” is
………………………………….

a- Set an app icon image on a phone, on any smart device, or in Google


play store.
b- Show the app icon in Android Studio title bar only.
c- Show the app icon in Android Studio emulator only.
d- Show this icon if this app is installed on IPhone devices only.
Answer: a
------------------------------------------------------------------------
Q18. Android SDK platform is a set of libraries and APIs that provide
necessary classes, methods and interfaces to develop Android
applications and allow you to compile your code.
a. True
b. False
Answer: a
-----------------------------------------------------------------------
Q19. The following Android code displays a Toast message. Which of the
following is the correct parameter to replace Toast.xyz in this line of
code? Toast.makeText(this,”Message saved as draft”,Toast.xyz).show( )
a- Toast.LENGTH_LONG
b- Toast.shortTime
c- Toast.sec.4
d- Toast.Time.4s
Answer :a

Q20. This image displays part of Android Studio tool bar. What does the
button illustrated with a red rectangle represent?
a. AVD Manager
b. Gradle Console.
c. Save App.
d. Save As App.
Answer: a
----------------------------------------------------------------------
Q21. Which of the following files has the correct name for a layout design
file of an activity in an Android app?
a. MainActivity.java or MainActivity.kt
b. activity_main.xml
c. Sample.class
d. Gradle.sql

Answer: b

Q22. Which of the following is true about the following line of code:
button.setOnClickListener({ })
a. It only saves changes in a text field.
b. It sets the number of clicks the user presses to run the application.
c. The system executes the code you write in setOnClickListener({ }) after
the user presses the button.
d. It sets the time and date of run process.
Answer: c
-------------------------------------------------------------------------------
Q23. Which of the following Android Studio folders includes drawable
files for different launcher icon densities?
a. Mipmap
b. Layout
c. Drawable
d. Values
Answer: a
--------------------------------------------------------------------------
Q24. Which of the following layouts is fully integrated with Android
Studio’s layout editor so you can build the full layout without the need to
edit the XML manually?
a. Constraint Layout
b. Linear Layout
c. Relative Layout
d. Table Layout Answer: a

--------------------------------------------------------------------
Q25. The following Android code will show the small popup message
“Message saved as draft” for 3.5 seconds, and then automatically
disappears: Toast.makeText(this, ”Message saved as draft”,
Toast.LENGTH_LONG).show( )

a. True
b. False
Answer: a

Q26. Which of the following is a key technlogy for implementing Android


apps?
a. Android Studio IDE (Integrated Development Environment),
b. Java
c. Android SDK (Software Development Kit)
d. All of the above.

Answer: d. All of the above.

Q27. One benefit of developing Android apps is the openness of the


platform. The
operating system is ________ and free. This allows you to view Android’s
source
code and see how its features are implemented.
a. proprietary
b. closed source
c. open source
d. None of the above.

Answer: c. open source.


-------------------------------------------------------------------------------
Q28. Unlike Apple’s ________ iOS, which is available only on Apple
devices,
Android is available on devices from dozens of original equipment
manufacturers
(OEMs) and through numerous telecommunications carriers worldwide.

a. open source
b. proprietary
c. universal access
d. None of the above.
Answer: b. proprietary

Q29. Which of the following statements is true?


a. Android apps are developed with Java—one of the world’s most widely
used
programming languages.
b. Java was a logical choice for the Android platform, because it’s
powerful, free,
open source and used by millions of developers.
c. Experienced Java programmers can quickly dive into Android
development,
using Google’s Android APIs (Application Programming Interfaces) and
others available from third parties.
d. All of the above.
Answer: d. All of the above.
--------------------------------------------------------------------------------------
Q30. GUI programming in Java is ________ , you’ll write apps that
respond to
various user-initiated events such as screen touches.

a. user driven
b. programmer driven
c. IDE driven
d. event driven.

Answer: d. event driven.


Q31. In addition to directly programming portions of your apps, you’ll
also use the
Android Studio IDE to conveniently ________ predefined objects such as
buttons and textboxes into place on your screen, and label and resize
them.
a. drag and drop
b. point and click
c. copy and paste
d. None of the above.

Answer: a. drag and drop.


--------------------------------------------------------------------------------
Q32: The multitouch screens allow you to control the device with
________ involving one touch or multiple simultaneous touches.
a. actions.
b. gestures.
c. gesticulations.
d. None of the above.

Answer: b. gestures.

Q33. Which gesture is used to flip item-by-item through a series, such as


photos?
a. drag.
b. long press.
c. pinch zoom.
d. swipe.

Answer: d. swipe.
---------------------------------------------------------------------------------------
Q34. ________ are software components stored on one computer that
can be accessed by an app (or other software component) on another
computer over the
Internet.
a. GUIs
b. Web services.
c. Classes.
d. None of the above.

Answer: b. Web services.

Q45.What is the name of the class used by Intent to store


additional information?
a. Extra
b. Parcelable
c. Bundle
d. DataStore
Answer: C

Q36.What is the name of the layout file for the main activity?
activity_main.xml

Q37.What is the name of the string resource that specifies the


application's name?
ApplicationId

Q38.Which tool do you use to create a new emulator?


AVD Manager.

Q39:Match.
View: a hierarchy of objects that is used with the UI on Android devices.
this class represents the basic building block for all UI (user interface)
components, and the base class for classes that provide interactive UI
components such as buttons, checkboxes, and text entry fields.

TextView: subclass of View: for displaying text.

EditText: subclass of View: to enable the user to enter and edit text.

Button: subclass of View: provides interactive behavior along with other


clickable elements (such as RadioButton, CheckBox, and Spinner).

ScrollView and RecyclerView: subclass of View: to display scrollable


items.
ImageView: subclass of View: for displaying images.

Q40:Which of the following is not an activity lifecycle state?


a. Started
b. Waiting
c. Created
d. Destroyed

Q41:Which lifecycle method is called to make an activity visible?


a. onPause()
b. onVisible()
c. onStart()
d. onDestroy()

Q42. What Activity method you use to retrieve a reference to an Android


view by using the id attribute of a resource XML?
a. findViewByReference(int id);
b. findViewById(int id)
c. retrieveResourceById(int id)
d. findViewById(String id)
Answer: B
Q43. Which of the following is not an Android component (i.e. a point
from which the system can enter your application)?
a.Service
b.Activity
c. Layout
d.Content Provider
Answer: C

Q44. During an Activity life-cycle, what is the first callback method


invoked by the system?
a. onStop()
b. onStart()
c. onCreate()
d. onRestore()
Answer: C
Q45. Which configuration file holds the permission to use the
internet?
a. Layout file
b. Property file
c. Java source file
d. Manifest file
Answer: D

Q46. Which of the following is NOT a valid usage for Intents?


a. Activate and Activity
b. Activate a Service
c. Activate a Broadcast receiver
d. Activate a SQLite DB Connection.
Answer: D
Q47. What is the name of the folder that contains the R.java file?
a. src
b. res
c. bin
d. gen
Answer: D

Q48. What is a correct statement about an XML layout file?


a. A layout PNG image file
b. A file used to draw the content of an Activity
c. A file that contains all application permission information
d. A file that contains a single activity widget.
Answer: B
Q49. What does the src folder contain?
a. Image and icon files
b. XML resource files
c. The application manifest file
d. Java source code files
Answer: D

Q50.Which of the following is not an Activity lifecycle call-back


method?
a. onStart
b. onCreate
c. onPause
d. onBackPressed
Answer: D

You might also like