0% found this document useful (0 votes)
135 views2 pages

Mobile Programming Exam Answers

The document provides answers to an exam on mobile programming, focusing on Android app development. Key topics include the primary programming language (Java), functions of mobile application components, the meaning of Intent, and reasons for Android's popularity. It also covers types of native applications, layout classes, XML code examples, and Java code snippets for handling user interactions.

Uploaded by

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

Mobile Programming Exam Answers

The document provides answers to an exam on mobile programming, focusing on Android app development. Key topics include the primary programming language (Java), functions of mobile application components, the meaning of Intent, and reasons for Android's popularity. It also covers types of native applications, layout classes, XML code examples, and Java code snippets for handling user interactions.

Uploaded by

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

MOBILE PROGRAMMING EXAM

ANSWERS
QUESTION ONE (COMPULSORY)
1. 1. Primary programming language used for Android app development:

Java is the primary language used for Android development. It’s preferred because it is
officially supported by Android, has a large community, extensive libraries, and robust tools
like Android Studio.

2. 2. Functions of mobile application components:

- onCreate() method: Called when an activity is first created. It initializes the activity, sets
up the UI, and restores previous state if available.
- Activity: Acts as a single screen with a user interface in Android. It manages user
interaction and UI lifecycle.

3. 3. Meaning of Intent:

An Intent is a messaging object used to request an action from another app component. It
can start activities, services, or broadcast messages.

4. 4. Two reasons why Android is preferred:

- Open-source and free: Developers can access and modify the Android OS.
- Wider market reach: Android powers a large percentage of global mobile devices.

5. 5. Three types of native mobile applications:

- Productivity Apps: E.g., Calendars, Note-taking apps


- Gaming Apps: Native games utilizing device performance
- Social Media Apps: E.g., Facebook, Instagram

6. 6. Three layout classes:

- LinearLayout: Arranges children in a single row or column.


- RelativeLayout: Positions children relative to each other or the parent.
- ConstraintLayout: Allows complex positioning with constraints between components.

7. 7. Meaning of namespace + Sample XML code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>

8. 8. Java code snippet to handle button clicks:

Button myButton = findViewById(R.id.my_button);


myButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Button clicked!",
Toast.LENGTH_SHORT).show();
}
});

9. 9. XML code for emulator output:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome to Android App!"
android:textSize="18sp" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me" />
</LinearLayout>

You might also like