The Ultimate 50 Android Multiple Choice Questions (MCQs) for Your Knowledge Test

Introduction to Android Operating System

Android is a mobile operating system that is composed of a stack of software including operating systems middleware and key applications. Each application runs on its own instance of the Dalvik virtual machine within its own process.

Android has many versions including Android 1.0, 1.1, 1.5, 1.6, 2.2, 2.3, with names such as Cupcake, Doughnut, and Gingerbread.

Advantages of Android

There are numerous benefits to using Android, some of which include:

* Open-source platform * Huge development community * Enhanced marketing opportunities * Inter-app integration * Reduced development costs * High success rate * Rich development environment

Android Architecture

The Android operating system is built on the following building blocks:

* Linux Kernel * Native libraries * Android Runtime * Application Framework * Applications

Android Building Blocks

The basic building blocks of the Android operating system are as follows:

* Activities * Services * Broadcast Receiver * Content Provider * Views

Android Libraries

The following libraries are included in Android:

* Android.app * Android.content * Android.database * Android.text * Android.view * Android.widget * Android.webkit

Android Multiple Choice Questions

Identifying Android as an Operating System

In this question, the answer is (B) Android is an Operating System. The other options are incorrect. Android is not a web browser or a web server.


// Code example of Android as an Operating System
// Initializing a variable to store the Android version
String androidVersion = "Android 11";
// Displaying the Android version
System.out.println("The current Android version is: " + androidVersion);


Understanding Android Activities

Android Activity is a component that represents a single screen with a user interface. It performs actions on behalf of the user and receives input events. Each activity is associated with one or more fragments which define its user interface. By using activities, developers can create a rich and interactive user experience for their Android applications.

Activities are implemented as subclasses of the

android.app.Activity

class and are defined in the AndroidManifest.xml file.

Verification of Android being built upon J2ME version of Java

The statement "Android is built upon the Java micro edition(J2ME) version of Java" is False. In fact, Android is built on the Java Development Kit (JDK), which is the standard Java platform for building desktop, mobile, and web applications.

Therefore, the correct answer is option B) False.


// No code required for this task


Android's Linux Foundation

In terms of operating system architecture, Android is based on the Linux kernel. This is because Linux provides several important features, such as networking, portability, and security, that are crucial for a successful mobile operating system. Therefore, the correct answer is (D) All of the above, as all of these reasons contribute to why Android is based on Linux.

Identifying the Virtual Machine used by Android Operating System

In order to identify the virtual machine used by the Android Operating System, we need to check the options below:

  • Dalvik operating system
  • JVM
  • Simple virtual machine
  • None

The correct answer is option A) Dalvik operating system.

Android runs on its own custom VM called the Dalvik Virtual Machine. It is different from the JVM as it is specifically designed and optimized for Android.

//code to get the Virtual Machine used by Android Operating System

String vm = "Dalvik"; //set default value
if(System.getProperty("java.vm.name").equalsIgnoreCase("Dalvik"))
{
   vm = "Dalvik";
}
System.out.println("Virtual Machine used by Android Operating System is: "+vm);

Identifying the programming language that Android is based on

To develop apps for Android, developers use the Java programming language. Java is an object-oriented programming language that is easy to learn and has a wide range of libraries and tools available to assist with development. It also has performance benefits that are ideal for use on mobile devices.


// Example of Java code for Android app
public class MainActivity extends AppCompatActivity {
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        TextView textView = findViewById(R.id.textView);
        textView.setText("Hello, World!");
    }
}


Layout Class Subclasses in Android

In Android, all layout classes are subclasses of

android.view.ViewGroup

.

Here's an example:


// Creating a LinearLayout object
LinearLayout linearLayout = new LinearLayout(context);
// Setting layout parameters
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
    LinearLayout.LayoutParams.MATCH_PARENT,
    LinearLayout.LayoutParams.MATCH_PARENT
);
// Setting the layout parameters on the LinearLayout
linearLayout.setLayoutParams(params);
// Adding the LinearLayout to the parent view
parentView.addView(linearLayout);

In this example, we are creating a

LinearLayout

object, which is a subclass of

ViewGroup

. We then set layout parameters for this layout and add it to a parent view.

Understanding APK in Android Development

In the world of Android development, APK refers to Android Package Kit, which is the file format used to distribute and install applications on Android devices. It contains all the necessary files and metadata required for the installation process.

It is important to note that an APK file is essentially a ZIP archive with a .apk extension. The file contains compiled code, resources, and other files, such as graphics and media, required for the app to run.

Hence, whenever you want to install an Android app, you would download and install the corresponding APK file from the Google Play Store or other trusted sources.

Manifest XML in Android

In Android, the manifest file is an XML file that contains all the necessary information about the application such as activities, services, permissions, and more. It describes the structure of the application, including its package name, permissions, version, and API levels. The manifest file provides essential information to the Android operating system to install, launch, and manage the application. Thus, option B "It has all the information about an application" is correct.

Understanding the Use of Content Providers in Android

Content providers in Android are used to share data between applications. They are primarily responsible for managing access to a structured set of data, typically stored in a database.

One major benefit of using content providers is that they provide a standardized interface for accessing data, making it easier for multiple applications to work with the same data source.

So, the answer to the question is C) For sending data from one application to another.

Testing Android Apps on Emulators and Physical Devices

During the development of Android applications, developers have several options to test their apps. These include:

  • Emulators in the Android SDK
  • Physical Android devices, such as phones or tablets
  • Third-party emulators

Developers can choose to test their apps on one or more of these sources to ensure that the app is functioning as intended on different devices.

The answer to the given question is D - apps can be tested on all of the above-mentioned sources.

Mini Activities in Android

In Android, mini activities are known as Fragments.


// Example code for Fragment:
public class ExampleFragment extends Fragment {
    // Fragment code here
}

Using fragments in Android can be beneficial in terms of reusability and flexibility in creating user interfaces.

Converting Java bytecode to Dalvik bytecode using dex compiler

The correct option to convert Java bytecode to Dalvik bytecode is the dex compiler. The dex compiler is a tool that is part of the Android SDK and is used to convert and package Java bytecode into Dalvik Executable (DEX) format files. This conversion is required because Android apps are written in Java, but the Android operating system uses Dalvik Virtual Machine to execute these apps.

The dex compiler optimizes and compresses the bytecode to make it more suitable for running on mobile devices with limited resources. The generated DEX files can be executed on any Android device.

Here's an example of how to use the dex compiler to convert Java bytecode to Dalvik bytecode:

java
// Input file - Java bytecode file
File input = new File("input.jar");

// Output file - Dalvik bytecode file
File output = new File("output.dex");

// Create the dex compiler object
DexCompiler dexCompiler = new DexCompiler();

// Convert the Java bytecode to Dalvik bytecode
dexCompiler.compile(input, output);

This code creates a dex compiler object and uses it to compile the input Java bytecode file into Dalvik bytecode format and store the output in the output file.

Stopping Services in Android

In Android, the methods that can be used to stop services are

stopSelf()

and

stopService()

.

Using the

system.exit()

method is not recommended since it will terminate the entire application and not just the service.

Similarly,

finish()

and

end()

methods are not applicable for services in Android.

Therefore, the correct answer is B)

stopSelf()

and

stopService()

method can be used to stop services in Android.

How to Kill an Activity in Android?

In Android, there are two methods to kill an activity: finishActivity() and finish(). The correct answer is D) Activity in Android can be killed using both finishActivity (int requestCode) and finish() method.

The finishActivity() method is used to finish an activity, and it takes an integer parameter requestCode.

The finish() method, on the other hand, is used to kill the current activity, and it does not take any parameters.

So, you can use either of the methods depending on your requirement.

Explaining the Full Form of ADB

In Android development, ADB stands for Android Debug Bridge. It is a versatile command-line tool that allows you to communicate with a device through your computer.

ADB lets you manage and control your Android device or emulator directly from your computer terminal. It helps developers in installing and debugging applications, copying files between computer and device, and executing shell commands.

Explanation:

The correct option is C) Android Virtual Device (AVD). AVD is an Android emulator for testing and running android apps on a computer instead of a real device. It allows developers to test their applications on multiple virtual devices with different configurations and versions of Android.

Option A) Active Virtual Display is an incorrect option. There is no such abbreviation used in the Android development context.

Option B) Android Virtual Display is also an incorrect option. AVD stands for "Android Virtual Device."

Option D) Active Virtual Device is an invalid option.

Code:


// This is a sample code
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
 
public class MainActivity extends Activity {
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
 
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
 
}

The above code is a basic template for creating a new Android application. It defines a MainActivity class that extends the Activity class. The Android system calls the onCreate() method when the activity is created for the first time. In this method, we are setting the activity_main.xml file as a view for this activity.

Identifying the Contained Option in the SRC Folder

The correct answer is B) Java source code is contained in the src folder.

Identifying the Parent Class of Activity

In Android, the parent class of the

activity

is the

ContextThemeWrapper

class. Therefore, the correct option is A)

contextThemeWrapper

.

The

ContextThemeWrapper

class is a special class that allows you to modify the theme of your application at runtime without modifying the application's code. It extends the

ContextWrapper

class and has a constructor that takes a theme as an argument.

The

activity

class is a subclass of

ContextThemeWrapper

and inherits all its properties and methods. It is used to represent a single screen in an Android application, and each screen is considered as an activity.

Code:
java
public class MyActivity extends Activity {
   // Activity code here
}

Identifying Error in Android Development using Logcat

Out of all the tabs given in Android Studio, the Logcat tab is primarily used for viewing and analyzing the log files generated during runtime. Developers often use it to debug applications and identify errors and bugs in their code.

Therefore, if you want to identify an error in your Android development project, you should check the Logcat tab in Android Studio. This tab will show all the logs generated during runtime, and any errors or exceptions will be highlighted in red.

Make sure to check the Logcat tab regularly while developing your Android application to catch any errors early on and fix them before they become bigger problems.

// Sample code for catching errors
try {
   // some code
} catch (Exception e) {
   Log.e(TAG, "Error Found: " + e.getMessage()); // log error
}

Open Handset Alliance Announcement Date

The correct answer is D) Open Handset Alliance was announced in 2007.

Topmost Layer of Android Architecture

In Android architecture, the topmost layer is the Application Framework.

The other layers are:

  • Linux Kernel
  • System Libraries
  • Android Runtime

The Application Framework is built on top of the lower layers and provides the developer with the tools and APIs to create powerful applications. These applications can then be installed and run on Android devices.

So, the correct answer is B) Applications Framework.

Identifying the Lowest Layer of Android Architecture

In Android architecture, the operating system is composed of four main layers: Applications, Applications Framework, System Libraries and Android Runtime, and Linux Kernel. Out of these four layers, the lowest layer is the Linux Kernel.

// Sample code showcasing the lowest layer of Android Architecture 
// Initializing the Linux Kernel 
 linux_kernel = new LinuxKernel(); 


State in the Service Lifecycle

In the service lifecycle, the state of a service can be one of the following:


    Service is Running
    Service is Starting
    Service is Stopped or Destroyed

Therefore, the answer is:

Answer: C) Paused is not a state in the service lifecycle.

Identifying Dialogue Classes in Android

In Android, all of the following are examples of dialogue classes:

DatePickerDialog
AlertDialog
ProgressDialog

Therefore, the correct answer is D) All of the above.

Choosing the Built-in Database for Android

In Android, the built-in database is SQLite, which is a lightweight, file-based, and open-source relational database that is used to store data on a device. It's designed to be an embedded database that is included with the application code. MySQL and Oracle, on the other hand, are not built-in databases for Android.

To utilize SQLite for data storage on an Android device, the SQLiteOpenHelper class can be used. This class provides the functionality to create and manage database files, tables, and columns. The SQLite database can be used to store various types of data such as text, integer, blob, and more.

Using the built-in database of Android can provide an efficient way to manage data for an application, as it can allow for persistent data storage and improved performance.

Accessing Android Database

In Android, to access the database, we make use of the android.database package, specifically the SQLiteDatabase class provided by the package. The correct answer is B) android.database.

This package allows us to create, update and delete a database or the tables within the database. It also provides us with methods to insert, update, delete and retrieve data from the database.

An example of accessing a database in Android:


    // create or open an existing database
    SQLiteDatabase myDatabase = this.openOrCreateDatabase("myDatabase", MODE_PRIVATE, null);

    // create a table within the database
    myDatabase.execSQL("CREATE TABLE IF NOT EXISTS myTable (id INTEGER PRIMARY KEY, name VARCHAR, age INT(3))");

    // insert data into the table
    myDatabase.execSQL("INSERT INTO myTable (name, age) VALUES ('John', 25)");

    // retrieve data from the table
    Cursor c = myDatabase.rawQuery("SELECT * FROM myTable", null);

Remember to close the database once you are done with it using myDatabase.close(), to avoid any potential memory leaks.

Explanation

The method `sendStickyBroadcast(intent)` is used to send an intent that can be seen by all receivers registered for it, but the intent is also "sticky," meaning that the most recent intent is kept in memory and sent to new receivers that register for it. This is useful when you want to pass information to receivers even if they were not actively running when the intent was initially sent. By using this method, the intent is stored in memory and can be accessed by any component that wants to use it.

Logging Debug Messages in Android Using Log.d()

In Android, Log.d() is a method used for logging debug messages. It is a part of the Android API and is used to print debug information useful for developers during app development and testing. Debug logging can help identify issues with your app and improve its overall performance.

Log.d()


Understanding ANR in Android

In Android, ANR (Application Not Responding) occurs when an app freezes or becomes unresponsive. Android versions 2.3 or higher are equipped with a watchdog timer that runs in the background, monitoring if an app is not responding for more than 5 seconds. If this occurs, the system displays an ANR dialog, allowing the user to close the app.

The full form of ANR is "Application not responding".

Subclasses of android.view.ViewGroup in Layout Classes

In Android, all layout classes are subclassed from the android.view.ViewGroup which is a subclass of android.view.View.

Therefore, the correct answer to this question is option C - android.view.ViewGroup.

It is important to note the correct naming conventions while referring to class names and package names in Java.


// Example of instantiation of a Layout Class
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

Identifying Android Layout for Arranging Children:

In Android, TableLayout arranges its child views in rows and columns, similar to a table in HTML. This type of layout is suitable for displaying tabular data and helps to organize the content in a structured manner. Therefore, the correct answer is C) TableLayout.


    // Example implementation using TableLayout
    TableLayout tableLayout = new TableLayout(context);
    
    // Create rows and columns with desired UI elements
    for(int i = 0; i < numRows; i++){
        TableRow tableRow = new TableRow(context);
        for(int j = 0; j < numCols; j++){
            TextView textView = new TextView(context);
            // Set text, style, and other properties of TextView
            tableRow.addView(textView);
        }
        tableLayout.addView(tableRow);
    }
    // Add tableLayout to parent view
    parentView.addView(tableLayout);

Understanding GCM

GCM stands for Google Cloud Messaging, not Google Centre messaging as stated in one of the options. It is a service provided by Google that allows for the delivery of messages from servers to devices.

Option C, "Google account," is grammatically incorrect and does not make sense in the given context. Similarly, option D, "None account manager," is also grammatically incorrect and does not provide a relevant option.

The correct answer is B, "Google Cloud messaging."

Definition of Nine-Patch Images Tool in Android

The Nine-Patch Images tool in Android is used to change bitmap images into nine sections.

Understanding JSON

In the context of web development, JSON stands for JavaScript Object Notation. It is a lightweight data-interchange format that is easy for humans to read and write, and easy for machines to parse and generate. It is often used to transfer data between a server and a web application, as an alternative to XML.

In short, JSON is a standardized format for representing data as key-value pairs, similar to a dictionary or object in JavaScript. Its syntax is based on the syntax of JavaScript objects, but it can be used with any programming language that supports data structures such as arrays and objects.

For example, here is a simple JSON object representing information about a person:

{ 
  "name": "John Doe",
  "age": 30,
  "city": "New York"
}

In this example, "name", "age", and "city" are the keys, and "John Doe", 30, and "New York" are the corresponding values.

How to Find JSON Element Length in Android JSON

In Android JSON, to find the length of a JSON element, we can use the `length()` function.

For example:


String jsonStr = "{\"people\":[{\"name\":\"John\",\"age\":\"25\"}, 
                                {\"name\":\"Mary\",\"age\":\"32\"}], 
                      \"count\":2}";

try {
    JSONObject jsonObj = new JSONObject(jsonStr);
    
    //get the JSON array 'people'
    JSONArray peopleArr = jsonObj.getJSONArray("people");
    
    //get the number of elements in the JSON array 'people'
    int peopleArrLength = peopleArr.length();
    
    //get the value of 'count' element
    int countVal = jsonObj.getInt("count");
    
} catch (JSONException e) {
    e.printStackTrace();
}

In this example, `peopleArr.length()` returns the number of JSON elements in the `people` array, which is 2, and `jsonObj.getInt("count")` returns the value of the `count` element, which is 2 as well.

Note that we need to handle the `JSONException` in case the JSON string is malformed.

Understanding Transient Data in Android

In Android, transient data refers to data that is temporary and can be lost at any time. This type of data is referred to as logical data, which includes data stored in memory variables, caches, and other temporary locations. It is stored in the RAM and is not secure or permanent.

Secure data, on the other hand, is data that is encrypted and requires special permissions to access, such as user's login credentials or credit card information. It is stored in a secure database or file on the device.

Permanent data is data that is stored permanently on the device, such as user settings, preferences, or application data. It is stored in a database or file on the device, and remains even when the device is turned off or restarted.

Therefore, option D - temporary data - is the correct answer.

// Example of transient data in Android
String username = "JohnDoe";
int age = 25;
// this data is stored in memory and can be lost at any time

Android's Web Browser Base

The base for Android's web browser is the open-source WebKit. It is not Safari, Firefox, or Chrome.

Explanation:

The ViewPager is used for swiping fragments. A Fragment represents a behavior or a portion of user interface in an Activity. Fragments are used to facilitate re-use and modularization of code. When used with a ViewPager, the user can swipe through many fragments belonging to the same activity. The ViewPager displays one fragment at a time and the user can swipe to move between fragments. This allows users to easily browse through a large amount of content in a single activity without cluttering the screen.

Kernel of Android OS

Android OS is based on the Linux kernel.

//no code to optimize, just a simple answer


Techniques to Refresh Dynamic Content in Android

To refresh dynamic content in Android, we can use the AJAX technique.

AJAX (Asynchronous JavaScript and XML) is a web development technique that allows for asynchronous data exchange between a web browser and a web server. In Android, we can use AJAX to fetch real-time data from the server and update the UI without refreshing the entire web page.

Using AJAX, we can refresh specific parts of the UI and provide a smoother user experience. This technique is commonly used in mobile applications with dynamic content such as social media, news, and weather apps.

Android License

Android is licensed under the Apache/MIT open-source license.

 
// code example
public class AndroidLicense {
   String licenseType = "Apache/MIT"; 
}

What does OHA stand for?

OHA stands for Open Handset Alliance.

The Open Handset Alliance (OHA) is a consortium of technology companies that was established in 2007 with the goal of developing open standards for mobile devices. The most famous product to emerge from the OHA is Google's Android operating system, which is used by millions of people around the world.

Identification of Android Application Framework File

The Android application framework is provided in the Jar file.


Answer - B) Jar file


Package for Supporting SQL Libraries in Android

The

javax.*

package is used for supporting SQL libraries in the Android framework.

What is WAP?

WAP stands for Wireless Application Protocol. It is a communication protocol for wireless devices such as mobile phones and PDAs. It allows access to the internet and other related services.

Identifying Components of Android Architecture

This question assesses your knowledge of the Android architecture system library and Android runtime layer. The correct answer is option D since SSL, DVM, and WebKit are all components of this layer. The SSL library provides secure network communication; DVM (Dalvik Virtual Machine) is an Android-specific virtual machine that executes code compiled for it. Finally, Webkit provides the rendering engine for the Android web browser and other applications that use HTML rendering.


// No code needed for this question


Who Manages Data Sharing Between Applications?

In Android, data sharing between applications is managed by content providers.

Developer of DVM

DVM was developed by Dan Bornstein.

// No code to show


What is WebKit?

WebKit is a browser engine used by many popular web browsers to render web pages. It was originally created by Apple for their Safari browser and is now also used by Google Chrome and many other browsers.


// Example of using WebKit in JavaScript
const webkitBrowser = new WebKitBrowser();
webkitBrowser.loadPage("https://example.com"); 


What does AAPT stand for?

AAPT

stands for Android Asset Packaging Tool.

What is the Full Form of NDK?

In the context of Android development, NDK stands for Native Development Kit.

The correct answer is B) Native Development Kit.

Which programming language is used by WAP?

The programming language used by WAP is Wireless Markup Language (WML).

WML is a markup language that was designed specifically for wireless devices, allowing them to display web pages in a format optimized for smaller screens and lower memory and processing power.

Technical Interview Guides

Here are guides for technical interviews, categorized from introductory to advanced levels.

View All

Best MCQ

As part of their written examination, numerous tech companies necessitate candidates to complete multiple-choice questions (MCQs) assessing their technical aptitude.

View MCQ's
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.