V20PCA204 - Android Application Development
V20PCA204 - Android Application Development
V20PCA204 - Android Application Development
10 questions, each carrying 1 mark per unit. [50 MCQ's with answers]
1. What is splash screen in android?
A - Initial activity of an application
B - Initial service of an application
C - Initial method of an application
D - Initial screen of an application
Correct Answer: D
2. What is JSON in android?
A - Java Script Object Native
B - Java Script Oriented Notation
C - Java Script Object Notation
D - None of the Above
Correct Answer: C
3. What is an interface in android?
A - Interface acts as a bridge between class and the outside world.
B - Interface is a class.
C - Interface is a layout file.
D - None of the above
Correct Answer: A
4. Android Is Developed by
A - Apple.
B - Samsung.
C - Google
D - AndroidInc
Correct Answer: D
5. Android web browser is based on
A - Chrome
B – Open Source web kit.
C - Google
D – Firebox
Correct Answer: B
6. Parent class of Activity?
A ) object
B ) context
C ) activityGroup
D ) contextThemeWrapper
Correct Answer: D
7. Which are the screen densities in Android?
A) low density
B) medium density
C) extra high density
D) all of the above
Correct Answer: D
8. Which are the screen sizes in Android?
A) small
B) normal
C) large
D) all of the above
Correct Answer: D
9. Layouts in android?
A) Frame Layout
B) Linear Layout
C) Relative Layout
D) All of the above
Correct Answer: D
10. Creating a UI (User Interface) in Android requires careful use of…
A ) 2005
B ) 2006
C ) 2007
D ) 2008
Correct Answer: C
12. What file is responsible for glueing everything together, explaining what the application
consists of, what its main building blocks are, ext.…?
A ) Layout file
B ) Strings XML
C ) R file
D ) Manifest file
Correct Answer: D
13.Android Software Package is based on
A) Linux OS
B) Windows OS
C) Mac OS
D) None of these
Correct Answer: A
14.Full form of OHA
A) Open Hand Application
B) Open Handset Alliance
C) Open Handset Application
D) Out Handset Alliance
Correct Answer: B
15.Full form of DVM
A) Dell Virtual Model
B) Dev virtual machine
C) Dalvik virtual machine
D) Dalvik virtual Model
Correct Answer: C
16.What does the .apk extension stand for?
A ) Application Package
B ) Application Program Kit
C ) Android Proprietary Kit
D ) Android Package
Correct Answer: A
17.The ___________ file specifies the layout of your screen?
A ) Layout file
B ) Manifest file
C ) Strings XML
D ) R file
Correct Answer: A
18.When developing for the Android OS, Java byte code is compiled into what?
▪ A ) SQLite
B ) Apache
C ) MySQL
D ) Oracle
Correct Answer: A
20.What is contained within the manifest xml file?
36. Which among the following are part of "Application" layer of Android Architecture?
A. Contacts
B. Browser
C. Phone
D. All of these
Correct Answer: D
37. 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
Correct Answer: D
38. The android library that provides access to UI pre-built elements such as buttons, lists,
views etc. is
A. android.text
B. android.os
C. android.webkit
D. android.view
Correct Answer: C
39. What was the first phone released that ran the Android OS?
A. Google gPhone
B. T-Mobile G1
C. Motorola Droid
D. HTC Hero
Correct Answer: B
40. During an Activity life-cycle, what is the first callback method invoked by the system?
A. onStop()
B. onStart()
C. onCreate()
D. onRestore()
Correct Answer: C
A. Embedded relational
B. Non-embedded relational
C. Non-relational
D. Structural
A. Open-source
B. Closed-source
C. Open-end
D. Open-wire
A. Read
B. Written
C. Both A and B
D. None of the above
44. Typically, a single disk file contains the entire SQL database, including ____ and
views.
A. Tables
B. Indices
C. Triggers
D. All of the above
A. Interface
B. Non-interface
C. Portable
D. Non-portable
46. For your programming language to access that database, you'll need an SQLite
____.
A. Powerplug
B. Extension
C. Structure
D. Database
A. Totally free
B. Serverless
C. Very flexible
D. All of the above
48. Which of the following layout in android aligns all children either vertically or
horizontally?
a. RelativeLayout
b. TableLayout
c. FrameLayout
d. LinearLayout
49. Which of the following class in android displays information for a short period of time
and disappears after some time?
a. toast class
b. log class
c. maketest class
d. None of the above
A. onCreate() −> onStart() −> onActivityStarted() −> onResume() −> onPause() −>
onStop() −> onActivityDistroy() −> onDestroy()
B. OnCreate() −> onStart() −>onResume() −> onPause() −> onStop() −> onRestart() −>
onDestroy()
C. OnCreate() −> onStart() −> onPause() −> onResume() −> onStop() −> onDestroy()-
−>onResume()
D. All of the above
Correct Answer: B
1. Android Architecture:
o Describe the components of Android architecture and their roles.
o Explain the interaction between different layers of Android architecture.
o Discuss the importance of Linux Kernel, Android Runtime, and Application
Framework in Android system.
2. Activity Lifecycle:
o Draw and explain the lifecycle diagram of an Android activity.
o Describe each method in the activity lifecycle with its purpose.
o How does the activity lifecycle affect the behavior of an Android application?
5. Android Components:
o Define and differentiate between activities, services, broadcast receivers, and
content providers.
o Explain when and why each Android component type is used in application
development.
o How are intents used to communicate between components in Android?
9. Advanced Topics:
o Discuss the implementation of Google Maps API in an Android application.
o Explain how to use sensors (e.g., accelerometer, GPS) in Android
development.
o Describe the MVVM architecture and how it can be implemented in Android
using ViewModel and LiveData.
21. What is the WebView and Toast? Write the code to call in JAVA:
● WebView: WebView is a widget in Android that allows displaying web pages within
an Android application. It's essentially a browser embedded into the app.
// Example code to load a web page in a WebView
WebView webView = findViewById(R.id.webView);
webView.loadUrl("https://www.example.com");
Toast: Toast is a small message that pops up on the screen to display information to
the user for a short period of time.
// Example code to display a toast message
Toast.makeText(getApplicationContext(), "Hello, World!",
Toast.LENGTH_SHORT).show();
PART C
2 Long Answer questions with answers per unit with answers (pattern - 2 questions of
10 marks each) Total 10 Questions.
● Media library provides support to play and record an audio and video formats.
● Surface manager responsible for managing access to the display subsystem.
● SGL and OpenGL both cross-language, cross-platform application program
interface (API) are used for 2D and 3D computer graphics.
● SQLite provides database support and FreeType provides font support.
● Web-Kit This open source web browser engine provides all the functionality to
display web content and to simplify page loading.
● SSL (Secure Sockets Layer) is security technology to establish an encrypted link
between a web server and a web browser.
Linux Kernel –
Linux Kernel is heart of the android architecture. It manages all the available drivers such as
display drivers, camera drivers, Bluetooth drivers, audio drivers, memory drivers, etc. which
are required during the runtime.
The Linux Kernel will provide an abstraction layer between the device hardware and the
other components of android architecture. It is responsible for management of memory,
power, devices etc.
The features of Linux kernel are:
● Security: The Linux kernel handles the security between the application and the
system.
● Memory Management: It efficiently handles the memory management thereby
providing the freedom to develop our apps.
● Process Management: It manages the process well, allocates resources to
processes whenever they need them.
● Network Stack: It effectively handles the network communication.
● Driver Model: It ensures that the application works properly on the device and
hardware manufacturers responsible for building their drivers into the Linux build.
<EditText
android:id="@+id/editTextNum1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:hint="Enter number 1"
android:inputType="numberDecimal"
android:layout_centerHorizontal="true"/>
<EditText
android:id="@+id/editTextNum2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/editTextNum1"
android:layout_marginTop="16dp"
android:hint="Enter number 2"
android:inputType="numberDecimal"
android:layout_centerHorizontal="true"/>
<Button
android:id="@+id/buttonAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/editTextNum2"
android:layout_marginTop="16dp"
android:text="+"
android:onClick="onAddButtonClick"
android:layout_alignStart="@id/editTextNum1"/>
<Button
android:id="@+id/buttonSubtract"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/editTextNum2"
android:layout_marginTop="16dp"
android:text="-"
android:onClick="onSubtractButtonClick"
android:layout_toEndOf="@id/buttonAdd"/>
<Button
android:id="@+id/buttonMultiply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/buttonAdd"
android:layout_marginTop="16dp"
android:text="*"
android:onClick="onMultiplyButtonClick"
android:layout_alignStart="@id/editTextNum1"/>
<Button
android:id="@+id/buttonDivide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/buttonAdd"
android:layout_marginTop="16dp"
android:text="/"
android:onClick="onDivideButtonClick"
android:layout_toEndOf="@id/buttonMultiply"/>
<EditText
android:id="@+id/editTextResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/buttonMultiply"
android:layout_marginTop="16dp"
android:hint="Result"
android:inputType="numberDecimal"
android:enabled="false"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_calculator);
editTextNum1 = findViewById(R.id.editTextNum1);
editTextNum2 = findViewById(R.id.editTextNum2);
editTextResult = findViewById(R.id.editTextResult);
}
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initialize views
usernameEditText = findViewById(R.id.usernameEditText);
passwordEditText = findViewById(R.id.passwordEditText);
loginButton = findViewById(R.id.loginButton);
activity_main.xml
<EditText
android:id="@+id/usernameEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"
android:layout_marginTop="100dp"
android:padding="10dp"/>
<EditText
android:id="@+id/passwordEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:layout_below="@id/usernameEditText"
android:layout_marginTop="20dp"
android:padding="10dp"/>
<Button
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:layout_below="@id/passwordEditText"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"
android:padding="10dp"/>
</RelativeLayout>
1. <manifest>: The root element of the manifest file that contains essential information
about the app, such as its package name and version code.
2. <application>: Encloses all the components of the application, including activities,
services, broadcast receivers, and content providers. It also defines application-wide
properties and permissions.
3. <activity>: Declares an activity in the application. Each activity represents a screen
with a user interface.
4. <service>: Declares a background service that performs long-running operations
without a user interface.
5. <receiver>: Declares a broadcast receiver component that responds to system-wide
broadcast announcements.
6. <provider>: Declares a content provider component that manages a shared set of app
data.
7. <intent-filter>: Specifies the types of intents that the component can respond to. It
defines the actions, categories, and data types supported by the component.
8. <uses-permission>: Declares permissions required by the application to access
certain system features or perform specific actions.
build.gradle File:
The build.gradle file is a configuration file used by the Gradle build system to customize the
build process of an Android project. It defines build settings, dependencies, and other
configurations specific to the project. Here are the key components of the build.gradle file:
1. buildscript: Defines the dependencies and repositories required for the build script
itself.
2. dependencies: Specifies the dependencies required by the project, such as libraries,
plugins, and other external modules.
3. android: Configures settings for the Android build, such as compile SDK version,
build types (debug, release), product flavors, and build variants.
4. defaultConfig: Specifies default configurations for the app, such as application ID,
version code, version name, minimum SDK version, and target SDK version.
5. repositories: Specifies the repositories where Gradle should look for dependencies,
such as Maven Central, Google Maven, or local repositories.
6. task: Defines custom tasks or modifies existing tasks in the build process.
Android AlertDialog can be used to display the dialog message with OK and Cancel
buttons. It can be used to interrupt and ask the user about his/her choice to continue or
discontinue.
Android AlertDialog is composed of three regions: title, content area and action
buttons.
Android AlertDialog is the subclass of Dialog class.
Methods of AlertDialog class
Method Description
public AlertDialog.Builder setTitle(CharSequence) This method is used to set the title of AlertDialog.
public AlertDialog.Builder setMessage(CharSequence) This method is used to set the message for AlertDialog.
public AlertDialog.Builder setIcon(int) This method is used to set the icon over AlertDialog.
XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="example.javatpoint.com.alertdialog.MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button"
android:text="Close app"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
JAVA
package example.javatpoint.com.alertdialog;
import android.content.DialogInterface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.app.AlertDialog;
import android.widget.Toast;
//Uncomment the below code to Set the message and title from the
strings.xml file
builder.setMessage(R.string.dialog_message) .setTitle(R.string.dialog_title)
;
a. Check Box
b. ImageButton
c. ImageView
d. RadioButton
e. Button
a. Check Box:
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Check Box" />
b. ImageButton:
<ImageButton
android:id="@+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/image" />
c. ImageView:
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/image" />
d. RadioButton:
<RadioButton
android:id="@+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Radio Button" />
e. Button:
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
9. How to use Google Maps API to implement location based services in an
application?
Google Maps API provides developers with powerful tools to integrate mapping and
location-based services into their Android applications. Here's a brief overview of how to use
Google Maps API for location-based services:
1. Obtain API Key: First, you need to obtain an API key from the Google Cloud
Platform Console. This key is required to access Google Maps API services.
2. Add Google Play Services Dependency: In your app's build.gradle file, include the
Google Play Services dependency to access Google Maps API features.
3. Add Map Fragment to Layout: In your XML layout file, add a
SupportMapFragment or MapView to display the map.
4. Initialize Google Maps: In your activity's onCreate() method, initialize Google
Maps by obtaining a reference to the GoogleMap object.
5. Set Up Map Configuration: Configure the map settings such as zoom controls, map
type, and other UI settings.
6. Access User's Location: To access the user's current location, you can use the
LocationManager or FusedLocationProviderClient to request location updates.
Ensure you have the necessary location permissions declared in the manifest file.
7. Add Markers and Overlays: You can add markers, polylines, polygons, and other
overlays to the map to provide additional information.
8. Handle Map Events: Implement event listeners to handle user interactions with the
map, such as clicks on markers or map gestures.
9. Customize Map Styling: Optionally, you can customize the map's appearance using
the Maps Styling feature to match your app's design.
10. Testing and Debugging: Test your application on real devices and emulators to
ensure proper functionality. Use debugging tools to troubleshoot any issues.
11. Deploy: Once your application is ready, deploy it to the Google Play Store or
distribute it through other channels.
10. How does the Wi-Fi technology work in Android explain using WifiManager ?
Wi-Fi technology in Android is managed through the WifiManager class, which provides
methods to enable/disable Wi-Fi, scan for available networks, connect to networks, and
obtain information about the device's Wi-Fi connection. Here's how Wi-Fi technology works
in Android using WifiManager:
By leveraging the WifiManager class and related APIs, developers can create Android
applications that interact with Wi-Fi networks effectively, providing users with enhanced
connectivity features and capabilities.