Sunday, May 5, 2019

Android



Multiple Answers

1.             To run your app on real device which is required
----           enable USB debugging on android device
----           install USB driver for window
----           plug android device into your system
2.             One can declare a logical parent “.MainActivity” to <activity> by adding the following line in the respective <activity> in AndroidManifest.xml.
----           android: parentactivityname=”.MainActivity”
3.             Button and textviews both inherits from the same android class name:
----           android.view.View
4.             Which of the following lifecycle methods are common to both activity and fragment?
----           onStart()
5.             The best practice is to put Strings value in ____ file.
----           strings.xml
6.             What is the difference between broadcast receiver and Intent filter?
----           A Broadcast receiver allows an app to register to be notified upon system or application events; an intent filter specifies which intent an app can receive.
7.             What is Retrofit?
----           A type safe client for consuming restful API’s in android and java in general.
8.             The ‘showAsAction’ attribute of <item> in menu resource file can have which of the following:
----           ‘ifRoom’
----           ‘withText’
----           ‘never’
9.             _____ are like reusable components or subactivities and can be reused between sub activities.
----           Fragments
10.          What must be done after a TypedArray is no longer needed?
----           The Recycle() must be manually called in order to notify the system that the object is no longer using memory allocated to it.
11.          What is Master Detail Pattern?
----           A Layout pattern consisting of a master layout (containing a collection of data) and detail (containing detailed information about an item from the collection)
12.          What is the purpose of a Loader?
----           Loaders are special-case data streams that provide a bytewise iterator when accessing files from external storage.
13.          Which superclass do most UI elements extend?
----           Activity
14.          Which of the following is true?
----           Activities are top-level classes that can contain and manage Fragments.
15.          The Strings.xml has ________ element
----           <resources>
16.          When publishing updates to an app on the Google Play Store, which of the following is true?
----           The keystore used to sign the APK to publish the app must match previous published versions.
----           The package name must be the same.
----           The versionCode must be incremented or higher than the previous published version.
17.          The addCategory() method places a category in an Intent object, ____ deletes a category previously added, and ____ gets the set of all categories currently in the object?
----           removeCategory()
----           getCategories()
18.          When defining a View within an XML layout, which two attributes are always required?
----           Width and Height
19.          Which feature of the Java build process allows for Android projects with more than 65k method calls?
----           Multidexing
20.          To pass extra information with intent we can use which intent method?
----           putextra()
21.          What are the Android Support Libraries for?
----           They allow features introduced in more recent versions of Android to be used on devices running older OS versions.
22.          What does the following code do?
try {
String token = GoogleAuthUtil.getToken(this, email, «https://www.googleapis.com/auth/devstorage.read_only»);
System.out.println(token);
} catch (IOException e) {
System.out.println(«IOException»);
} catch (UserRecoverableAuthException e) {
System.out.println(«UserRecoverableAuthException»);
} catch (GoogleAuthException e) {
System.out.println(«GoogleAuthException»);
}
----           prints token

23.          What is the purpose of the AppCompat library?

----           It allows the app to share content with other apps via the share intent.

24.          Which of the following is correct about Intent Filter?

----           Intent filters are defined inside AndroidManifest.xml

----           An Intent Filter also specifies a category

25.          Which statement converts the object into String?

----           none of the above

26.          What is Guava?

----           An open-source project consisting of common libraries for Java, maintained and primarily developed by Google.

27.          Which of the following is true for R.java?

----           R.java file is special Java file that’s get generated by the android tools whenever you create or build your tools.

----           Android uses R.java to keep track of the resources used within app.

----           It contain string resources.

28.          Which method sets the layout for the activity?

----           setContentView()

29.          Which file contains information about the app?

----           AndroidManifest.xml

30.          Which of the following correctly adds a string array resource to string.xml?

----           <string-array name:=”name”>

                                <item>string_value1</item>

                </string-array>

31.          What is the purpose of Volley?

----           Volley is an HTTP library that makes networking for Android apps easier and most importantly, faster.

32.          Which of the following are true for Intent?

----           If one activity wants to start a second activity

----           startactivity(intent)

----           Intent is an object.

33.          Which of the following is the correct location for the menu resource file?

----           res/menu/filename.xml

34.          Which of the following is not an activity lifecycle method?

----           onDetach()

35.          When creating main Android App project with Android studio, how can we support localization of the Android App?

----           main/res/values/strings.xml

36.          What does the following code do?

Calendar cal = Calendar.getInstance();
DateFormat dateFormat = new SimpleDateFormat(«yyyy-MM-dd»);
cal.add(Calendar.DATE, -1);
return dateFormat.format(cal.getTime());

----           Gets yesterday’s date and returns its formatted string

37.          Going to check network connection with below source code. What can be required to make it work?

public boolean isOnline() {
ConnectivityManager cm = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo != null && netInfo.isConnectedOrConnecting()) return true;
return false;

}

----           android.permission.ACCESS_NETWORK_STATE

38.          When does ANR occur?

----           When there has been no response to a user input event within 5seconds.

39.          What is an Intent Filter?

----           Provides the OS with the data types that an application can receive from an Intent triggered elsewhere

40.          To connect list view to array we can use:

----           ArrayAdapter

 


 

               









               

No comments:

Post a Comment