Reprinted online interview questions

Source: Internet
Author: User

Android interview questions

1.
Which of the following statements about memory reclaim are correct? (B)


A,
ProgramThe worker must create a thread to release the memory.


B,
The memory reclaim program is responsible for releasing useless memory.


C,
The memory reclaim program allows programmers to directly release the memory.


D,
The memory reclaim program can release memory objects at a specified time.

2.
The following exception is a runtime exception (ABCD) (multiple choice)


A. arithmeticexception


B. illegalargumentexception


C. nullpointerexception


D. bufferunderflowexception

3.

Math. Round (11.5) equals to (). Math. Round (-11.5) equals to (c). c


A, 11,-11
B, 11,-12
C, 12,-11
D, 12,-12

4.
The output result of the following program segments is: (B)

Void complicatedexpression_r (){

Int x = 20, y = 30;

Boolean B;

B = x> 50 & Y> 60 | x> 50 & Y <-60 | x <-50 & Y> 60 | x <-50 && Y <-60;

System. Out. println (B );

}

A, true
B. False
C, 1
D, 011. activity5.
Save some resources and status operations, preferably in which function of the Life Cycle (d)


A. onpause ()
B. oncreate ()
C. onresume ()
D. onstart ()

6.
Which of the following data types can be passed (ABCD) When intent transmits data (Multiple choices)


A. serializable
B. charsequence
C. parcelable
D. Bundle

7.
In Android, which of the following is intent? (c)


A. implement data sharing between applications


B. It is a long life cycle. programs without a user interface can keep the applications running in the background without switching the page.


C. You can switch between interfaces, including actions and action data, and connect the four components.


D. process the integrity of an application

8.
Which of the following are advantages of parsing XML files by using Sax? (B)


A. The entire document tree is stored in the memory, which is easy to operate and supports deletion, modification, and rescheduling.


B. The entire document does not need to be transferred in advance, which consumes less resources.


C. The entire file is transferred to the memory, which wastes time and space.


D. The data does not reside in the memory for a long time and is not persistent. After the event, if the data is not saved, the data will

Disappear

9.
Which of the following methods is correct for custom Styles? ()


A. <resources>


<Style name = "mystyle">


<Item name = "Android: layout_width"> fill_parent </item>


</Style>


</Resources>


B. <style name = "mystyle">


<Item name = "Android: layout_width"> fill_parent </item>


</Style>


C. <resources>


<Item name = "Android: layout_width"> fill_parent </item>


</Resources>


D. <resources>


<Style name = "Android: layout_width"> fill_parent </style>


</Resources>

10.
When using menu in Android, you may need to override (AC ). (Multiple options)


A. oncreateoptionsmenu ()


B. oncreatemenu ()


C. onoptionsitemselected ()


D. onitemselected ()

11.
Run the following T-SQL statement in SQL Server Management studio with the output value (c ).


Select @ identity


A. It may be 0.1


B. It may be 3

C. Impossible-100


D. It must be 0.

12.
Run the following T-SQL statement in SQL Server 2005, assuming that the sales table has multiple rows of data, the result after the query is (d ).


Begin transaction

Update sales set qty = 30 Where qty <30

Begin transaction B


Update sales set qty = 40 where qty <40


Update sales set qty = 50 where qty <50


Update sales set qty = 60 Where qty <60

Commit transaction B

Commit transaction


A. the minimum value of the qty column in the sales table is greater than or equal to 30.


B. the minimum value of the qty column in the sales table is greater than or equal to 40.


C. The data in the qty column in the sales table is all 50


D. the minimum value of the qty column in the sales table is greater than or equal to 60.

13.
When sqliteopenhelper is used in Android, a database can be generated and the database version can be managed by (AB)


A. getwriteabledatabase ()


B. getreadabledatabase ()


C. getdatabase ()


D. getabledatabase ()

14.
Which of the following statements about oncreate () and onstart () in the service lifecycle of Android is true? (AD) (multiple choice questions)


A. The oncreate () and onstart () methods are called successively at the first startup.


B. When it is started for the first time, only the oncreate () method is called.


C. If the service has been started, the oncreate () and onstart () methods will be called successively.


D. If the service has been started, only the onstart () method is executed, not the oncreate () method.

15.
Which of the following is the glsurfaceview feature (ABC) (multiple choice)


A. Manage a surface. This surface is a special memory that can be directly typesented to the android view.


View.


B. Manage An EGL display, which enables OpenGL to render the content to the above surface.


C. Let the Renderer operate in an independent thread and separate it from the UI thread.

D. image data can be obtained directly from hardware interfaces such as memory or DMA.

16.
Which of the following is the correct method for registering broadcastreceiver in the androidmanifest. xml file? ()

A. <Cycler Android: Name ="Newbroad">


<Intent-filter>


<Action


Android: Name ="Android. provider. Action. newbroad"/>


<Action>


</Intent-filter>

</Cycler>


B. <Cycler Android: Name ="Newbroad">


<Intent-filter>


Android: Name ="Android. provider. Action. newbroad"/>


</Intent-filter>


</Cycler>


C. <Cycler Android: Name ="Newbroad">


<Action


Android: Name ="Android. provider. Action. newbroad"/>


<Action>


</Cycler>


D. <intent-filter>


<Cycler Android: Name ="Newbroad">

<Action>


Android: Name ="Android. provider. Action. newbroad"/>

<Action>

</Cycler>

</Intent-filter>

17.
Which of the following statements about the contenvalues class is true? ()


A. He is similar to hashtable and is also responsible for storing some name-value pairs, but


The name is of the string type, and the value is of the basic type.


B. He is similar to hashtable and is also responsible for storing some name-value pairs, but


The name is of any type, and the value is of the basic type.


C. He is similar to hashtable and is also responsible for storing some name-value pairs, but


Name, which can be null, and the values are of the string type.


D. He is similar to hashtable and is also responsible for storing some name-value pairs, but among the name-value pairs he stores


Is of the string type, and the value is of the string type.

18.
We all know that hanlder is a bridge between threads and activities. If the thread is improperly processed, your machine will become slower, and the thread destruction method will be ()


A. ondestroy ()


B. onclear ()


C. onfinish ()


D. onstop ()

19.
The method for exiting the activity below is (c)


A. Finish ()

B. Throwing an exception and force exit


C, system. Exit ()


D. onstop ()

20.
Which of the following Android animation categories are (AB) (multiple)


A. Tween
B. Frame C, draw D, and animation

21.
Which of the following statements about the android DVM process and the Linux Process is true for the application process? (d)


A. DVM refers to the Virtual Machine of dalivk. every android application runs in its own process and does not necessarily have an independent Dalvik Virtual Machine instance. every DVM is a process in Linux, so it can be considered the same concept.


B. DVM refers to the Virtual Machine of dalivk. every android application runs in its own process and does not necessarily have an independent Dalvik Virtual Machine instance. every DVM is not necessarily a process in Linux, so it is not a concept.


C. DVM refers to the Virtual Machine of dalivk. every android application runs in its own process and has an independent Dalvik Virtual Machine instance. every DVM is not necessarily a process in Linux, so it is not a concept.


D. DVM refers to the Virtual Machine of dalivk. every android application runs in its own process and has an independent Dalvik Virtual Machine instance. every DVM is a process in Linux, so it can be considered the same concept.

22.

What is the role of the Assets Directory In the android project? B

A. Place the image resources to be applied.

B. Mainly store multimedia and other data files

C. Place string, color, array, and other constant data

D. place some layout files corresponding to the UI, which are XML files.

23.

Which of the following statements about the Res/raw directory is true? ()

A. The files here are not converted to binary format after they are stored on the device.

B. The files are stored on the device and converted to binary format.

C. The files are finally stored in the specified package in binary format.

D. The files here will not be stored in the specified package in binary format.

24.
Which of the following statements about Android ndk is true? (ABCD)

A. ndk is a collection of tools

B. ndk provides a stable and functional API header file statement.

C. Finally, the development method of "Java + C" has become officially supported.

D. ndk will be the beginning of C development on the Android platform.

II.Blank question

25.

The four la s commonly used in Android are:Framlayout, Linenarlayout, RelativelayoutAnd tablelayout. 26.

The four main components of Android are:Activiey, Service, BroadcastAnd contentprovide.27.

In the java. Io packageObjectinputstreamAndObjectoutputstreamClass is mainly used to read and write objects. 28.

In Android, the service implementation method is:StartserviceAnd bindservice. 29.

Activity usually reloads 7 methods to maintain its lifecycle,Oncreate (), onstart (), ondestory ()
BesidesOnrestart, onresume, onpause, onstop.30.

Android Data StorageSharedpreference, File,SQLite, contentprovider,Network. 31.
When an activity is started and the new activity is executed, the callback function that starts the activity is returned.Startactivityresult ().32.
Use the command line to create a directory named myavd and SDK Version 2.2. the SD card is under the root directory of drive D and named scard. IMG, and specify the screen size of hvga .____________________________________. 33.

The program runs as follows :_____ Good and GBC__________.


Public class example {

String STR = new string ("good ");

Char [] CH = {'A', 'B', 'C '};

Public static void main (string ARGs []) {

Example EX = new example ();

Ex. Change (ex. STR, Ex. ch );

System. Out. Print (ex. Str + "and ");

Sytem. Out. Print (ex. ch );

}

Public void change (string STR, char ch []) {

STR = "test OK ";

Ch [0] = 'G ';

}

}

34.
In Android, briefly describe the JNI call process. (8 points)

1) install and download cygwin and Android ndk


2) Design of the jni interface in the ndk Project


3) use C/C ++ to implement local methods


4) JNI generates the dynamic link library. So file


5) copy the dynamic link library to the Java project, call it in the Java project, and run the Java project.

35.
Briefly describe the Android Application structure? (7 points)

The Android Application structure is:


Linux Kernel (Linux kernel), libraries (system Runtime library or C/C ++ core library), Application


Framework (Development Framework Package), applications
(Core applications)

36.
Inherit from sqliteopenhelper implementation: (10 points)


1) create a "diaryopenhelper. DB" database with version 1,


2). Create a "Diary" table (including a _ id Primary Key and auto-increment, topic category 100

Length, Content Encoding type 1000 length)


3) when the database version changes, delete the diary table and recreate the diary table.

Public class dbhelper
Extends sqliteopenhelper {


Public final static string databasename = "diaryopenhelper. DB ";


Public final static int databaseversion = 1;


// Create a database


Public dbhelper (context, string name, cursorfactory factory, int Version)


{


Super (context, name, factory, version );


}


// Create institutional files such as tables


Public void oncreate (sqlitedatabase dB)


{


String SQL = "CREATE TABLE Diary" +


"(" +


"_ Id integer primary key autoincrement," +


"Topic varchar (100)," +


"Content varchar (1000)" +


")";


Db.exe csql (SQL );


}


// Call this method if the database version is updated.


Public void onupgrade (sqlitedatabase dB, int oldversion, int newversion)


{



String SQL = "Drop table if exists Diary ";


Db.exe csql (SQL );


This. oncreate (db );


}

}

37.
The progressbar control is available on the page. Use the writing thread to display the progress in 10 seconds. (10 points)

Answer

Public class progressbarstu extends activity {


Private progressbar = NULL;


Protected void oncreate (bundle savedinstancestate ){


Super. oncreate (savedinstancestate );


Setcontentview (R. layout. progressbar );


// From here to below is the key


Progressbar = (progressbar) findviewbyid (R. Id. progressbar );



Thread thread = new thread (New runnable (){



@ Override


Public void run (){


Int progressbarmax = progressbar. getmax ();


Try {


While (progressbarmax! = Progressbar. getprogress ())


{



Int stepprogress = progressbarmax/10;


Int currentprogress = progressbar. getprogress ();


Progressbar. setprogress (currentprogress + stepprogress );


Thread. Sleep (1000 );


}



} Catch (interruptedexception e ){


// Todo auto-generated Catch Block


E. printstacktrace ();


}



}


});



Thread. Start ();


// Key end


}


}

38.
Describe the lifecycle of an activity.

Three required methods: oncreate () --> onstart () --> onresume (), represented by aaa

(1) The parent activity starts the activity and the Child actvity exits. The Calling sequence of the parent activity is as follows:
AAA --> onfreeze () --> onpause () --> onstop () --> onrestart () --> onstart (), onresume ()...
(2) The user clicks home and the actvity call sequence is as follows:
AAA --> onfreeze () --> onpause () --> onstop () -- maybe --> ondestroy ()-Maybe
(3) Call finish (). The activity call sequence is as follows:
AAA --> onpause () --> onstop () --> ondestroy ()
(4) display dialog on the activity. The call sequence of the activity is as follows:
Aaa
(5) display transparent or non-full screen activity on the parent activity. The call sequence of the activity is as follows:
AAA --> onfreeze () --> onpause ()
(6) the device enters the sleep state. The activity call sequence is as follows:
AAA --> onfreeze () --> onpause ()

39.
If the background activity is recycled by the system for some reason, How can I save the current status before it is recycled by the system?

Onsaveinstancestate ()

When one activity a in your program is running, it actively or passively runs another activity B. At this time, a will execute onsaveinstancestate (). B will come to a again after it is completed. There are two situations at this time: A is recycled, and A is not recycled. A will call oncreate () again when it is recycled () the method is different from the method in which the savedinstancestate parameter is included in oncreate (). If it is not recovered, the onresume () is executed directly and the oncreate () is skipped.

40.
How to Set an activity as a window style.

In androidmanifest. android: theme = "@ Android: style/theme. dialog "or Android: theme =" @ Android: style/theme. translucent "becomes translucent

41.
How to exit the activity? How can I safely exit the application that has called multiple activities?

for an application of a single activity, it is easy to exit. Simply finish.
Of course, you can also use methods such as killprocess () and system. Exit.
however, for a Multi-activity application, the above method is useless if you want to directly exit the last opened activity after opening multiple activities, this is because all the above methods end an activity.
Of course, some people on the Internet say yes.
someone may ask how to capture the Home key in an application. Someone may say that you can use keycode to compare keycode_home. In fact, if you do not modify the framework, it is impossible to do this.
try it yourself.
is there a way to exit the entire application directly?
you can use the restartpackage method of activitymanager before 2.1.
it can directly end the entire application. Android. Permission. restart_packages is required for use.
be careful not to be confused by its name.
however, in 2.2, this method fails.
A new method named killbackgroundprocesses () is added in 2.2. the permission Android. Permission. kill_background_processes is required.
unfortunately, like restartpackage 2.2, it does not have the expected effect.
another method is to force the termination of the program in the Application Management System, forcestoppackage ().
the permission Android. Permission. force_stop_packages is required.
Android: shareduserid = "android. UID. system "attribute
unfortunately, this method is not public and can only run in system processes, but cannot be called by third-party programs.
because local_certificate: = platform must be added to Android. mk.
Android. mk is used to compile programs in the android source code.
from the above, we can see that in 2.2, there is no way to end an application directly, but you can only use your own method to do it indirectly.
several methods are provided for reference:

1. Throw an exception and force Exit:
This method causes the program to force close by throwing an exception.
Yes, but the problem to be solved is how to end the program without the force close window.

2. Record the opened activity:
Every time an activity is opened, it is recorded. When you need to exit, close every activity.

3. Send specific broadcasts:
Send a specific broadcast when you need to end the application. After each activity receives the broadcast, close it.

4. Recursive exit
Use startactivityforresult when opening a new activity, add a flag on your own, process it in onactivityresult, and disable it recursively.
Except for the first one, we try to end every activity and achieve the goal indirectly.
However, this is not perfect.
If your application sets nosensor for each activity, the sensor may be valid during the gap between the two activities.
But at least, our goal has been achieved without affecting user usage.
For programming convenience, it is best to define an activity base class to deal with these common problems.

42.
This section describes five la s commonly used in Android.

Framelayout (Framework layout), linearlayout (linear layout), absolutelayout (absolute layout), relativelayout (relative layout), tablelayout (table layout)

43.
This section describes how to store Android data.

I. sharedpreferences

Ii. File Storage Methods

Iii. SQLite database Method

4. Content Provider

V. Network Storage

44.
This section describes how contentprovider achieves data sharing.

Create a content provider of your own or add your data to an existing content provider, provided that you have the same data type and the permission to write to the content provider.

45.
How to enable and disable a service.

In Android, a service is similar to a service in windows. A service generally does not have a user interface and is not easy to detect when running in the system,

You can use it to develop programs such as monitoring.

I. Procedure

Step 1: Inherit the service class

Public class smsservice extends Service {}

Step 2: In the androidmanifest. xml file, <Application>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.