[go: up one dir, main page]

0% found this document useful (0 votes)
20 views6 pages

Mobile Programming VVI Solved 2025

The document provides a comprehensive overview of mobile programming concepts related to Android, including definitions of key components such as Activity, Intent, Toast, RecyclerView, and SharedPreferences. It also covers the Android activity lifecycle, data passing between activities, and the use of SQLite for data storage. Additionally, it outlines Android architecture, steps to publish an app on the Play Store, and examples of implementing RecyclerView and background services.

Uploaded by

abhishek
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views6 pages

Mobile Programming VVI Solved 2025

The document provides a comprehensive overview of mobile programming concepts related to Android, including definitions of key components such as Activity, Intent, Toast, RecyclerView, and SharedPreferences. It also covers the Android activity lifecycle, data passing between activities, and the use of SQLite for data storage. Additionally, it outlines Android architecture, steps to publish an app on the Play Store, and examples of implementing RecyclerView and background services.

Uploaded by

abhishek
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Mobile Programming VVI Questions - Detailed Answers

Group A: Very Short Questions (1-2 Marks)


1. What is Android?

Ans: Android is an open-source mobile operating system developed by Google. It is based on the

Linux kernel and is designed primarily for touchscreen mobile devices such as smartphones and

tablets. It provides a rich application framework that allows developers to create innovative apps in

Java, Kotlin, or C++.

2. Define Activity.

Ans: An Activity in Android represents a single screen with a user interface. It is a crucial component

of an Android app and is used to interact with the user. Each activity is like a window or page where

UI components such as buttons, text fields, and images are displayed.

3. What is Intent?

Ans: Intent is a messaging object in Android used to request an action from another app component.

It can be used to start an activity, send a broadcast, or start a service. Intents can be explicit

(targeting a specific component) or implicit (requesting an action to be handled by other apps).

4. Define Toast in Android.

Ans: A Toast in Android is a small popup message that provides simple feedback about an

operation. It appears for a short period and automatically fades out. Toasts are ideal for showing

brief messages that do not require user interaction.

5. What is RecyclerView?

Ans: RecyclerView is a flexible and efficient view for displaying large data sets in Android. It is a

more advanced and improved version of ListView and GridView, supporting different layout

managers like LinearLayoutManager, GridLayoutManager, and StaggeredGridLayoutManager.

6. Define SharedPreferences.

Ans: SharedPreferences is an interface in Android used to store simple key-value pairs of primitive

data types. It is commonly used to save user preferences, settings, and session data locally on the

device.
7. What is Gradle?

Ans: Gradle is a build automation tool used in Android Studio to compile, build, and manage

dependencies for Android projects. It allows modular development, version control, and

customization through Groovy-based DSL scripts.

8. What is Manifest file?

Ans: The AndroidManifest.xml file is an essential part of an Android app. It contains important

information such as application components (activities, services, receivers), permissions, minimum

API level, hardware features, and more.

Group B: Short Answer Questions (4-6 Marks)


1. Explain Android activity lifecycle with diagram.

Ans: The Android activity lifecycle consists of several states through which an activity transitions

from its creation to destruction. These states are:

onCreate(): Called when the activity is first created. Used to initialize components.

onStart(): Called when the activity becomes visible.

onResume(): Called when the activity starts interacting with the user.

onPause(): Called when the activity is partially obscured by another activity.

onStop(): Called when the activity is no longer visible.

onRestart(): Called when the activity is being restarted after being stopped.

onDestroy(): Called before the activity is destroyed.

Diagram:

[onCreate] -> [onStart] -> [onResume] -> [onPause] -> [onStop] -> [onDestroy]

[onRestart]

2. Write code to pass data between two activities using Intent.

Ans: To pass data from Activity A to Activity B:


ActivityA.java:

Intent intent = new Intent(ActivityA.this, ActivityB.class);

intent.putExtra("key_name", "value");

startActivity(intent);

ActivityB.java:

String value = getIntent().getStringExtra("key_name");

3. Explain usage of RecyclerView in Android.

Ans: RecyclerView is used to display a large set of data efficiently. It improves performance by

reusing item views. It requires:

RecyclerView widget in layout

A layout manager (LinearLayoutManager, GridLayoutManager)

An adapter that binds data to view

A ViewHolder that describes item view and metadata

RecyclerView supports animations and custom layouts.

4. Write short note on SharedPreferences.

Ans: SharedPreferences in Android is used to store key-value pairs of primitive data types. It is

commonly used to save login session data or app preferences.

Example:

SharedPreferences prefs = getSharedPreferences("MyPrefs", MODE_PRIVATE);

SharedPreferences.Editor editor = prefs.edit();

editor.putString("username", "admin");

editor.apply();

5. Differentiate between implicit and explicit intent.

Ans: Explicit Intent:

Used to start a specific activity within the same app.

Example: Intent intent = new Intent(this, SecondActivity.class);


Implicit Intent:

Does not specify the target component.

Used to invoke components from other apps (e.g., share, call).

Example: Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://example.com"));

6. Explain Android UI components with examples.

Ans: Android UI components include:

TextView displays text.

EditText allows text input.

Button performs actions on click.

ImageView displays images.

CheckBox, RadioButton for multiple/single choices.

Spinner dropdown list.

These components are defined in XML or programmatically in Java/Kotlin.

7. How to store and retrieve data using SQLite in Android?

Ans: SQLite is a built-in database engine in Android. To use it:

Create a subclass of SQLiteOpenHelper.

Implement onCreate() to define schema.

Use getWritableDatabase() to insert/update/delete.

Use getReadableDatabase() for queries.

Example:

SQLiteDatabase db = helper.getWritableDatabase();

ContentValues values = new ContentValues();

values.put("name", "John");

db.insert("students", null, values);

Group C: Long Answer Questions (8-10 Marks)


1. Describe Android architecture in detail.
Ans: Android architecture consists of four layers:

1. Linux Kernel Handles device drivers, memory, power, and hardware abstraction.

2. Libraries & Android Runtime Includes C/C++ libraries like SQLite, WebKit, and ART (Android

Runtime) which runs the app bytecode.

3. Application Framework Provides high-level building blocks like Activity Manager, Location

Manager, Notification Manager.

4. Applications Topmost layer where user-installed and system apps reside (Contacts, Gallery,

etc.).

2. Write an Android app to add two numbers and display the result.

Ans: In activity_main.xml:

<EditText id='num1' />

<EditText id='num2' />

<Button id='btnAdd' />

<TextView id='result' />

MainActivity.java:

int a = Integer.parseInt(num1.getText().toString());

int b = Integer.parseInt(num2.getText().toString());

int sum = a + b;

result.setText("Sum: " + sum);

3. Explain the steps to publish an Android app on Play Store.

Ans: Steps to publish an app:

1. Create a signed APK/AAB.

2. Create a developer account on Google Play Console.

3. Upload your app with screenshots and details.

4. Set pricing, countries, and app content rating.


5. Submit for review. After approval, your app becomes live.

4. Write a complete example of using RecyclerView with custom adapter.

Ans: Steps:

1. Create item layout XML.

2. Create model class.

3. Create Adapter extending RecyclerView.Adapter.

4. Implement ViewHolder class inside Adapter.

5. Set adapter in Activity.

// In Activity

RecyclerView rv = findViewById(R.id.recyclerView);

rv.setLayoutManager(new LinearLayoutManager(this));

rv.setAdapter(new MyAdapter(dataList));

5. Explain background service in Android with example.

Ans: A background service performs long-running operations without UI. Example:

public class MyService extends Service {

public int onStartCommand(...) {

new Thread(() -> { /* background task */ }).start();

return START_STICKY;

// Register in manifest

<service android:name=".MyService" />

You might also like