Question Bank - ct1

You might also like

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

Question Bank

 List any four features of Android operating system

1. Open Source
2. User Interface
3. Mult-tasking
4. Connectivity (Wifi, BT, Hotspot, NFC)
5. Multi Touch
6. Multiple Language Support

 List any four folders from directory structure of Android project and elaborate in one line

1. Manifests Folder: Contains AndroidManifest.xml for creating the android application.


2. Java Folder: Contains all the java and Kotlin source code files that are created during app
development.
3. res (Resources) Folder: Contains all the non-code sources like images, XML layouts, and UI
strings for the android application.
4. Drawable
5. layout
6. Gradle Scripts: Contains scripts required for building the application.

 Describe Android architecture with diagram.

Applications
 This is the top layer, and it's what you interact with as a user. It includes all the apps you
download and use on your phone, such as games, social media apps, and more.
Application Framework
 This layer provides the building blocks that apps need to run. It includes things like:
o Activity Manager: Manages the lifecycle of activities, which are the screens you see
within an app.
o View System: Renders the UI for apps.

o Resource Manager: Manages app resources, such as images and strings.

o Notification Manager: Handles notifications for apps.

Libraries
 This layer provides pre-written code that developers can use to build their apps. It includes things
like:
o Android SDK: Provides core classes and APIs for Android development.

o Support Library: Provides additional APIs that are compatible with older versions of
Android.
Android Runtime (ART)
 This layer is responsible for running Android apps. It includes:
o Dalvik Virtual Machine (DVM): Executes Android app code.

o Android Runtime: Provides additional features for running Android apps, such as garbage
collection and security.
Linux Kernel
 This is the core of the Android system. It provides low-level access to hardware, such as the
camera and microphone. It also handles things like memory management and security.

 Explain OHA

OHA stands for Open Handset Alliance, which is a consortium of technology companies dedicated to
the development and advancement of open standards for mobile devices, particularly smartphones.
OHA's most notable initiative is the development and promotion of the Android platform, an open-
source operating system for mobile devices.
- OHA member companies Supported the open platform concept for a several reasons:
1. Lower overall handset costs
2. Developer-friendly environment
3. Post-development

 Describe Android ecosystem.


The Android ecosystem is a vast and intricate network of components that work together to deliver the
Android experience.
 Hardware: Diverse range of devices: smartphones, tablets, smartwatches, TVs, wearables, etc.
from various manufacturers (Samsung, Google, Xiaomi, etc.).
 Software:
o Operating System: Open-source Android with different customizations from
manufacturers (e.g., Samsung One UI, Xiaomi MIUI) and forks (e.g., Fire OS).
o Apps: Massive collection of apps in Google Play Store (official) and alternative stores.

o Services: Google Mobile Services (GMS) including Gmail, Maps, Drive, etc. (not
included in all regions).
 Developers: Large and active community developing apps and contributing to open-source
projects.
 Openness: Based on open-source principles, allowing customization and development of forks
like LineageOS.
 Fragmentation: Variety of devices and customizations can lead to compatibility issues and
different update timelines.
 Security: Regular security updates from Google and manufacturers, but fragmentation can create
vulnerabilities.
 Integration: Increasing focus on multi-device experiences with tools like Fast Pair and Nearby
Share.
 Competition: Competing ecosystems like iOS from Apple and Fire OS from Amazon.

Chapter2
 Differentiate between DVM and JVM

 Write down the steps to install and configure Android studio


 Define Android Virtual Devices (AVD).
 Define Dalvik Virtual Machine (DVM)

o JVM is high performance and provides excellent memory management. But it needs to be
optimized for
o low-powered handheld devices as well.
o The Dalvik Virtual Machine (DVM) is an android virtual machine optimized for mobile
devices. It
o optimizes the virtual machine for memory, battery life and performance.
o Dalvik is a name of a town in Iceland. The Dalvik VM was written by Dan Bornstein.
o The Dex compiler converts the class files into the .dex file that run on the Dalvik VM.
Multiple class files
o are converted into one dex file.
Chapter3
 Explain with example, code to create GUI using absolute layout (Assume suitable data

<?xml version="1.0" encoding="utf-8"?>


<AbsoluteLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint = "Name"
android:layout_x = "100dp"
android:layout_y = "100dp"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint = "Age"
android:layout_x = "100dp"
android:layout_y = "200dp"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint = "Mob No."
android:layout_x = "100dp"
android:layout_y = "300dp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:layout_x = "100dp"
android:layout_y = "400dp"/>
</AbsoluteLayout>

 Explain relative layout with attributes and example


 Develop a simple calculator using table layout.

<?xml version="1.0" encoding="utf-8"?>


<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TableRow>
<EditText
android:id="@+id/num1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter number 1" />
</TableRow>
<TableRow>
<EditText
android:id="@+id/num2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter number 2" />
</TableRow>
<TableRow>
<Button
android:id="@+id/add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"/>
<Button
android:id="@+id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Subtract"/>
<Button
android:id="@+id/mul"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Multiply"/>
<Button
android:id="@+id/div"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Divide"/>
</TableRow>
<TableRow>
<TextView
android:id="@+id/result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Result ="/>
</TableRow>
</TableLayout>

package com.example.tablecalc;

import android.os.*;
import android.app.*;
import android.view.*;
import android.widget.*;

public class MainActivity extends Activity


{
EditText et1, et2;
Button add, sub, mul, div;
TextView tv;
protected void onCreate(Bundle b)
{
super.onCreate(b);
setContentView(R.layout.activity_main);
et1 = findViewById(R.id.num1);
et2 = findViewById(R.id.num2);
add = findViewById(R.id.add);
sub = findViewById(R.id.sub);
mul = findViewById(R.id.mul);
div = findViewById(R.id.div);
tv = findViewById(R.id.result);
add.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
int a = Integer.parseInt(et1.getText().toString());
int b = Integer.parseInt(et2.getText().toString());
int c = a + b;
tv.setText("Result = " + c);
}
});
sub.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
int a = Integer.parseInt(et1.getText().toString());
int b = Integer.parseInt(et2.getText().toString());
int c = a - b;
tv.setText("Result = " + c);
}
});
mul.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
int a = Integer.parseInt(et1.getText().toString());
int b = Integer.parseInt(et2.getText().toString());
int c = a * b;
tv.setText("Result = " + c);
}
});
div.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
int a = Integer.parseInt(et1.getText().toString());
int b = Integer.parseInt(et2.getText().toString());
int c = a / b;
tv.setText("Result = " + c);
}
});
}
}

 Observe the following GUI and write an XML file using relative layout to create the
same.

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding = "50dp">

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "Top"
android:textSize="50sp"
android:layout_centerHorizontal="true"

/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "Bottom"
android:textSize = "50sp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom = "true"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "Left"
android:textSize = "40sp"
android:layout_alignParentLeft = "true"
android:layout_centerVertical = "true"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "Right"
android:textSize = "40sp"
android:layout_alignParentRight = "true"
android:layout_centerVertical = "true"/>
</RelativeLayout>

a) Develop a program to perform addition, subtraction ,division and multiplication of


two numbers and display the result. (XML and JAVA files).
Chapter4
 List any four attributes of check box

o android:id: This is used to uniquely identify a checkbox within the layout1.


o android:layout_width and android:layout_height: These are used to set the width and
height of the checkbox1.
o android:text: This is used to set the text that will be displayed alongside the checkbox1.
o android:checked: This is used to set the initial checked state of the checkbox1.
o android:clickable: This is used to enable or disable click events on the checkbox1.
o android:button: This is used to set a custom drawable for the checkbox2.
o android:state_checked: This is used to define different drawables for checked and
unchecked states3.

 Explain Radio group with example .


 Write program to display rectangular progress bar
 State syntax to create Text View and Image button with any two attributes of each
 Write a program to demonstrate Date and Time picker.

1) Write program to implement Time Picker

activity_main.xml
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<TimePicker
android:id="@+id/timePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:timePickerMode="clock"
/>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/timePicker"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:text="Get Time"
/>
</RelativeLayout>

MainActivity.java

package com.example.datepicker;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.*;

import java.sql.Time;

public class MainActivity extends Activity


{
TimePicker tp;
Button btn;
protected void onCreate(Bundle b)
{
super.onCreate(b);
setContentView(R.layout.activity_main);
tp = (TimePicker)findViewById(R.id.timePicker);
tp.setIs24HourView(false);
btn = (Button)findViewById(R.id.button);
btn.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
String time = tp.getHour() + ":" + tp.getMinute();
Toast.makeText(getApplicationContext(), time,
Toast.LENGTH_SHORT).show();
}
});

}
}

2) Write program to implement Date Picker

activity_main.xml
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<DatePicker
android:id="@+id/datePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:datePickerMode="spinner"
/>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/datePicker"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:text="Get Date"
/>
</RelativeLayout>

MainActivity.java

package com.example.datepicker;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.*;

public class MainActivity extends Activity


{
DatePicker dp;
Button btn;
protected void onCreate(Bundle b)
{
super.onCreate(b);
setContentView(R.layout.activity_main);
dp = (DatePicker)findViewById(R.id.datePicker);
btn = (Button)findViewById(R.id.button);
btn.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
String date = "Date: " + dp.getDayOfMonth() + "/" + (dp.getMonth() +
1) + "/" + dp.getYear();
Toast.makeText(getApplicationContext(), date,
Toast.LENGTH_SHORT).show();
}
});

}
}

 Write a program to convert temperature from celcius to farenhite and vice versa using
Toggle button. (Design UI as per your choice. Write XML and java file)

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<EditText
android:id = "@+id/temp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:hint="Enter Temp"/>
<TextView
android:id = "@+id/result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/temp"
android:layout_centerHorizontal="true"/>
<ToggleButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/result"
android:layout_centerHorizontal="true"
android:id="@+id/tBtn"
android:textOn="Show Celsius"
android:textOff="Show Fahrenheit"/>
</RelativeLayout>

package com.example.tempconvert;

import android.app.*;
import android.widget.*;
import android.os.*;
import android.view.*;

public class MainActivity extends Activity


{
ToggleButton tBtn;
EditText et;
TextView tv;
protected void onCreate (Bundle b)
{
super.onCreate(b);
setContentView(R.layout.activity_main);
tBtn = (ToggleButton)findViewById(R.id.tBtn);
et = (EditText)findViewById(R.id.temp);
tv = (TextView)findViewById(R.id.result);

tBtn.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
if(tBtn.isChecked())
{
double c = Double.parseDouble(et.getText().toString());
double f = (c*9/5)+32;
tv.setText(f+"F");
}
else
{
double f = Double.parseDouble(et.getText().toString());
double c = (f-32)*5/9;
tv.setText(c+"C");
}
}
});
}
}

 Design UI using table layout to display buttons with 0 – 9 numbers on it. Even display
submit and clear button. When user clicks on particular buttons and later when clicks on
submit button, it should display the numbers clicked

 Write the directory path where images are stored while developing Android application.
 List all attributes to develop a simple button .
 Android Project directory structure

o App
o Manifests
 AndroidManifest.xml
o Java
 MainActivity.java
o Res
 Drawable
 Layout
 Mipmap
 Values
o Gradle Scripts

You might also like