Android Application Programming (1)
Android Application Programming (1)
Which directory in an Android project stores XML files for the user
interface?
a) drawable
b) values
c) layout
d) res
Answer: c) layout
What is stored in the values directory of an Android project?
a) Image resources
b) XML files for strings, colors, and dimensions
c) Layout files
d) Manifest files
Answer: b) XML files for strings, colors, and dimensions
Which file defines the application's metadata, such as package name
and permissions?
a) MainActivity.java
b) AndroidManifest.xml
c) styles.xml
d) build.gradle
Answer: b) AndroidManifest.xml
Where are the Java or Kotlin source code files located in an Android
project?
a) res directory
b) java or src directory
c) layout directory
d) gradle directory
Answer: b) java or src directory
Which directory is used for storing app icons and image resources?
a) drawable
b) layout
c) mipmap
d) assets
Answer: a) drawable
Which folder is responsible for the app's compiled code?
a) lib
b) bin
c) gen
d) build
Answer: d) build
What is the role of the assets directory?
a) To store user interface components
b) To store non-compiled files like fonts and raw files
c) To store Java classes
d) To manage build configurations
Answer: b) To store non-compiled files like fonts and raw files
Which file contains the Gradle build configuration for the app module?
a) build.xml
b) build.gradle
c) AndroidManifest.xml
d) settings.gradle
Answer: b) build.gradle
Which directory contains the localization files for an Android app?
a) raw
b) values
c) assets
d) res
Answer: b) values
What is the purpose of the proguard-rules.pro file in an Android
project?
a) To define app layouts
b) To optimize and obfuscate code during release builds
c) To manage resources
d) To handle lifecycle callbacks
Answer: b) To optimize and obfuscate code during release builds
Which is NOT a fundamental screen component in Android?
a) TextView
b) Button
c) ProgressBar
d) FragmentManager
Answer: d) FragmentManager
Which component is used to display a single line of editable text?
a) TextView
b) EditText
c) ImageView
d) CheckBox
Answer: b) EditText
What is the role of the ImageView component?
a) To display images in the app
b) To capture user input
c) To show loading progress
d) To create layouts
Answer: a) To display images in the app
Which component is used for clickable items that trigger actions?
a) TextView
b) Button
c) RadioButton
d) ImageView
Answer: b) Button
Which component is used for user selection between multiple options?
a) ProgressBar
b) Switch
c) Spinner
d) LinearLayout
Answer: c) Spinner
What does a ProgressBar indicate in an app?
a) Static content display
b) Current progress of a task
c) Layout management
d) Dropdown menu options
Answer: b) Current progress of a task
Which attribute is mandatory for defining a UI component in XML?
a) padding
b) id
c) layout_width and layout_height
d) background
Answer: c) layout_width and layout_height
Which component allows the user to select one or more items from a
group?
a) RadioButton
b) CheckBox
c) Spinner
d) SeekBar
Answer: b) CheckBox
What is the default orientation of a LinearLayout?
a) Vertical
b) Horizontal
c) Undefined
d) Grid-based
Answer: a) Vertical
Which component is used for organizing items into scrollable lists?
a) RecyclerView
b) LinearLayout
c) RelativeLayout
d) ScrollView
Answer: a) RecyclerView
Which layout arranges its children in a single row or column?
a) LinearLayout
b) RelativeLayout
c) FrameLayout
d) AbsoluteLayout
Answer: a) LinearLayout
What is the primary drawback of AbsoluteLayout?
a) Complex UI design
b) Fixed positioning, which does not adapt to different screen sizes
c) Lack of support for nested layouts
d) High memory usage
Answer: b) Fixed positioning, which does not adapt to different screen
sizes
Which layout allows overlapping of child elements?
a) LinearLayout
b) FrameLayout
c) RelativeLayout
d) TableLayout
Answer: b) FrameLayout
Which layout uses a table-like structure for UI design?
a) TableLayout
b) GridLayout
c) RelativeLayout
d) FrameLayout
Answer: a) TableLayout
Which layout allows child elements to be positioned relative to each
other or the parent?
a) RelativeLayout
b) LinearLayout
c) FrameLayout
d) TableLayout
Answer: a) RelativeLayout
Which layout was introduced to simplify UI design with flexible grid
positioning?
a) AbsoluteLayout
b) GridLayout
c) TableLayout
d) LinearLayout
Answer: b) GridLayout
What attribute is used to specify the alignment of children in a
LinearLayout?
a) gravity
b) layout_gravity
c) orientation
d) padding
Answer: a) gravity
What is the default alignment in a RelativeLayout?
a) Top-left corner
b) Center
c) Right-aligned
d) Bottom-aligned
Answer: a) Top-left corner
Which layout is ideal for UI components that need to stretch to fill the
parent?
a) FrameLayout
b) RelativeLayout
c) ConstraintLayout
d) AbsoluteLayout
Answer: c) ConstraintLayout
Which layout was deprecated due to poor scalability and adaptability?
a) RelativeLayout
b) AbsoluteLayout
c) FrameLayout
d) LinearLayout
Answer: b) AbsoluteLayout
What is the function of a ScrollView?
a) To display images
b) To allow scrolling of a long UI
c) To manage relative positioning
d) To organize child elements into a table
Answer: b) To allow scrolling of a long UI
Which layout is used to design flexible, multi-device UIs?
a) GridLayout
b) ConstraintLayout
c) AbsoluteLayout
d) TableLayout
Answer: b) ConstraintLayout
Which directory in an Android project contains resource files used to
define user interface strings?
a) layout
b) raw
c) values
d) assets
Answer: c) values
What is the purpose of the res/drawable directory?
a) To store images and graphic resources
b) To hold string resources
c) To store XML files for layouts
d) To manage build configurations
Answer: a) To store images and graphic resources
Which file is essential for launching an Android application?
a) MainActivity.java
b) styles.xml
c) AndroidManifest.xml
d) strings.xml
Answer: c) AndroidManifest.xml
Which of the following is NOT part of an Android app's directory
structure?
a) assets
b) classes
c) res
d) libs
Answer: b) classes
What is stored in the res/raw folder?
a) Media files like videos or MP3s
b) Layout files
c) Precompiled Java files
d) XML configuration files
Answer: a) Media files like videos or MP3s
Which directory is specifically used for high-density screen resources?
a) res-mdpi
b) res-hdpi
c) res-xhdpi
d) res-xxhdpi
Answer: d) res-xxhdpi
Which of the following is a layout manager in Android?
a) ProgressBar
b) FrameLayout
c) TextView
d) Button
Answer: b) FrameLayout
Which UI component is used to capture touch inputs for gestures?
a) ScrollView
b) GestureDetector
c) LinearLayout
d) GridLayout
Answer: b) GestureDetector
What is the main difference between ListView and RecyclerView?
a) RecyclerView is deprecated
b) RecyclerView supports ViewHolder for performance
c) ListView supports better animations
d) ListView requires less memory than RecyclerView
Answer: b) RecyclerView supports ViewHolder for performance
Which component is used to display a circular loading indicator?
a) ProgressBar
b) CircularImageView
c) ImageButton
d) Spinner
Answer: a) ProgressBar
Which attribute is used to make a TextView editable?
a) android:clickable
b) android:editable
c) android:inputType
d) android:focusable
Answer: c) android:inputType
Which component would you use for a menu that pops up upon a
button click?
a) Dialog
b) PopupMenu
c) Spinner
d) ScrollView
Answer: b) PopupMenu
What is the use of android:hint in an EditText field?
a) To display an error message
b) To provide a default value
c) To show a placeholder text
d) To change the font size
Answer: c) To show a placeholder text
Which layout component is NOT scrollable by default?
a) RecyclerView
b) ScrollView
c) LinearLayout
d) ListView
Answer: c) LinearLayout
Which UI component is ideal for creating toggle switches?
a) Button
b) CheckBox
c) Switch
d) Spinner
Answer: c) Switch
Which attribute is used to align components within a LinearLayout?
a) android:layout_gravity
b) android:layout_align
c) android:layout_weight
d) android:layout_margin
Answer: a) android:layout_gravity
Which layout organizes UI elements in a tabular format?
a) FrameLayout
b) TableLayout
c) RelativeLayout
d) LinearLayout
Answer: b) TableLayout
What does the layout_weight attribute do in a LinearLayout?
a) Specifies the height of the component
b) Distributes space among child elements
c) Aligns the component to the parent
d) Sets the padding of the layout
Answer: b) Distributes space among child elements
Which attribute is used to define margins in a layout?
a) android:padding
b) android:spacing
c) android:margin
d) android:alignment
Answer: c) android:margin
Which layout arranges its children relative to the edges or each other?
a) ConstraintLayout
b) FrameLayout
c) RelativeLayout
d) TableLayout
Answer: c) RelativeLayout
What is the primary advantage of ConstraintLayout?
a) Fixed positioning
b) Lightweight memory usage
c) Flexible positioning for multi-device design
d) Allows overlapping of child elements
Answer: c) Flexible positioning for multi-device design
What happens when two child components in a LinearLayout have the
same layout_weight?
a) One takes precedence
b) They share space equally
c) The second one gets more space
d) It creates an error
Answer: b) They share space equally
Which layout type is deprecated due to its poor scalability?
a) AbsoluteLayout
b) GridLayout
c) ConstraintLayout
d) TableLayout
Answer: a) AbsoluteLayout
Which layout is best suited for overlapping UI components?
a) FrameLayout
b) RelativeLayout
c) TableLayout
d) ConstraintLayout
Answer: a) FrameLayout
Which layout requires a unique ID for each component for relative
positioning?
a) RelativeLayout
b) FrameLayout
c) TableLayout
d) AbsoluteLayout
Answer: a) RelativeLayout
Which of the following is NOT a valid layout in Android?
a) AbsoluteLayout
b) CardLayout
c) TableLayout
d) FrameLayout
Answer: b) CardLayout
Which layout is used for dividing a UI into equal-sized grids?
a) TableLayout
b) GridLayout
c) ConstraintLayout
d) FrameLayout
Answer: b) GridLayout
Which attribute of a LinearLayout defines the direction of child
components?
a) android:orientation
b) android:layout_gravity
c) android:alignment
d) android:scrolling
Answer: a) android:orientation