You are on page 1of 41

Grile android

1.

Which method allows users to use a file for writing in the internal storage?

a. openFileInput

b. openFileReading

c. openFileWriting

d. openFileOutput

e. saveToInternalStorage

d. openFileOutput is the method that allows users to use a file for writing in the internal
storage.

In Android, the openFileOutput method is used to open a private file associated with this
Context's application package for writing. It takes in two arguments:

1. The name of the file to open or create.

2. The operating mode. It can be one of two options: MODE_PRIVATE or


MODE_APPEND. MODE_PRIVATE is the default mode, it will create the file (or
overwrite it if it already exists) and make it private to your application.
MODE_APPEND will open the file and append to it if it already exists.

2.

Which statements are correct for the following file description?

{“item”:[{“name”:”Popescu”},{“name”:”Ionescu”}]}

a. a json array containing a json object with the property item and values Popescu and
Ionescu
b. a json object containing a property name with value Popescu
c. a json object containing a property item with and array of json objects
d. a json object containing a property item with the values name, Popescu and Ionescu
e. a json array containing one single element

R:

c. a json object containing a property item with an array of json objects

The file description provided is a JSON object. The object has one property called "item",
which has a value of an array. The array contains two JSON objects, each with a single
property "name" and a value of "Popescu" and "Ionescu" respectively. Therefore, option c is
correct as it describes that there is a json object containing a property item with an array of
json objects.

3.

What are the true statements regarding the following snippet of code?

Private Button button;


@Override
Protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
button.setOnClickListener(this);
}

a. the button is instructed to search for the onClick method at activity level
b. the button doesn’t know how to handle the on click event
c. the button uses anonymous classes for managing the on click event
d. the activity must override the onClick(View view) method
e. the activity is forced to implement the View.OnClickListener interface

d. the activity must override the onClick(View view) method is correct.

e. the activity is forced to implement the View.OnClickListener interface is correct.

The code snippet is defining a private variable button of type Button, and in the onCreate()
method, it calls the setOnClickListener() method on the button object, passing in this as the
argument. This tells the button that when it is clicked, it should call the onClick() method on
the current object (which is the activity because this refers to the current object).
Therefore, the activity must override the onClick(View view) method in order to handle the
click event. Also, since the activity is setting the onClickListener, it means that the activity is
implementing the View.OnClickListener interface. Option a, b, c are not correct as the code
doesn't say anything about searching onClick method at activity level, doesn't say that the
button doesn't know how to handle the on click event or use anonymous classes for
managing the on click event.
a. the button is instructed to search for the onClick method at activity level

pentru ca avem button.setOnClickListener(this);

4.

Which are the wrong intent actions, NOT used for dialing a phone number?

a. ACTION_ANSWER
b. ACTION_CALL
c. ACTION_RING
d. ACTION_PHONE
e. ACTION_DIAL

a. ACTION_ANSWER is used to answer an incoming phone call, not for dialing a phone
number.

c. ACTION_RING is used to initiate a ringtone when a phone call is incoming, not for dialing a
phone number.

d. ACTION_PHONE is used to open the dialer app, not for dialing a phone number
specifically.

5.

What type of control can be used in conjunction with an adapter?

a. Spinner
b. WebView
c. ListView
d. AutoCompleteTextView
e. ToggleButton
f. GridView
g. ImageButton

c. ListView,
f. GridView are types of controls that can be used in conjunction with an adapter.
ListView and GridView are used to display a scrollable list of items. An adapter is
used to bind the data to the ListView or GridView, providing the elements to be
displayed in the list.

6.

What class could a custom adapter use to extend from?

a. BaseAdapter
b. GenericAdapter
c. StringAdapter
d. ListViewAdapter
e. CursorAdapter

a. BaseAdapter, e. CursorAdapter are classes that a custom adapter could use to


extend from.

BaseAdapter is a basic implementation of the Adapter interface, it is a generic


implementation that can be used for any type of data. CursorAdapter is a subclass of
BaseAdapter that is designed for use with Cursor data. It provides a way to bind
Cursor data to a ListView or GridView. CursorAdapter provides a more efficient way
to bind data to ListView or GridView by using database cursor.

7.

What class is used for translating geographics coordinates into street addresses or vice-a-
versa?

a. MapConverter
b. LocationProvider
c. Address
d. LocationManager
e. Geocoder
f. Geocoder is a class that is used for translating geographic coordinates into street
addresses or vice-versa. It allows to convert a street address or location name into a
latitude and longitude, and vice-versa. It can also be used to determine the address
corresponding to a given latitude and longitude and vice-versa. It can be used to
determine the country, city, and post code for a given latitude and longitude.

8.

Which method is NOT used for displaying the layout of an activity?

a. displayView()
b. setContentView()
c. setView()
d. setLayoutView()
e. displayLayout()

a. displayView() is not a method that is used for displaying the layout of an activity.

b. setContentView() is the method that is used for displaying the layout of an activity. It sets
the activity content from a layout resource. The resource will be inflated, adding all top-level
views to the activity.

c. setView() is not a method that is used for displaying the layout of an activity.

d. setLayoutView() is not a method that is used for displaying the layout of an activity.

e. displayLayout() is not a method that is used for displaying the layout of an activity.

9.

Which methods are used for initializing JSON objects?

a. getObjectFromJSON()
b. getObject()
c. getJSONObject()
d. getJSONArray()

The method getJSONObject() is used for initializing a JSONObject from a JSON formatted
string, or a Map or a JSONTokener.

The method getJSONArray() is used for initializing a JSONArray from a JSON formatted
string, or a JSONObject, or a Collection, or an Object array.
a. getObjectFromJSON() and b. getObject() are not used for initializing JSON objects.

10.

What statements are true regarding a Canvas object in Android?

a. a Canvas can receive a ShapeDrawable object


b. a Canvas can be associated with a Bitmap object
c. a Canvas can be sent as a parameter in the onDraw() method
d. a Canvas is used to draw objects on top of it
e. a Canvas is used to invalidate the view

b. a Canvas can be associated with a Bitmap object

c. a Canvas can be sent as a parameter in the onDraw() method

d. a Canvas is used to draw objects on top of it.

Canvas is an object that provides the methods for drawing on a bitmap. It receives a Bitmap
object as a parameter when it is created and can be used to draw shapes, text, and images
on the Bitmap.

It can be passed as a parameter in the onDraw() method of a custom view, where the view
can draw itself on the canvas.

e. Invalidating the view is not a direct responsibility of the Canvas, it is the process of
marking it as "dirty" and in need of redrawing, it can be achieved by calling the invalidate()
method on the view or using other methods such as postInvalidate().

a. A Canvas can be used to draw on a ShapeDrawable object, but it is not a direct receiver of
the ShapeDrawable, it is not something that you would use to "receive" a ShapeDrawable,
but rather something that can be used to draw on a ShapeDrawable.
11.

Which of the following methods is running on the UI thread?

a. run();
b. onProgressUpdate();
c. onPostExecute()
d. onPreExecute()
e. doInBackground()
f. publishProgress()

d. onPreExecute()
c. onPostExecute()
b. onProgressUpdate()

The methods onPreExecute(), onPostExecute() and onProgressUpdate() are all


running on the UI thread. These methods are part of the AsyncTask class and are
called automatically by the system. onPreExecute() is called before the background
task starts, onPostExecute() is called after the background task completes, and
onProgressUpdate() is called when the background task calls publishProgress()
method.

a. run() is not a method specific to AsyncTask, and it could be running on UI thread if


it is called on the main thread.
e. doInBackground() runs in a background thread, it is where the background task is
executed.
f. publishProgress() is called by the background task and it allows the task to update
the UI with progress information.

12.

Which methods are used for calling the onDraw() method of a View?

a. invalidate()
b. onDraw()
c. drawing()
d. onRedraw()
e. postInvalidate()
f. rePaint()

a. invalidate()

e. postInvalidate()

The methods invalidate() and postInvalidate() are used for calling the onDraw() method of a
View.

The invalidate() method marks the view as dirty and in need of redrawing, and it causes the
onDraw() method to be called immediately by the system.

The postInvalidate() method also marks the view as dirty and schedules a redraw, but it
allows the system to wait until the next frame before calling the onDraw() method.

b. onDraw() is a method in the View class that is called by the system, it's not a method that
is called by the developer.

c. drawing() d. onRedraw() and e. rePaint() are not used for calling the onDraw() method of
a View.

13.

Inside any method of an Activity class, the pointer this is referred to as a:

a. Component
b. View
c. Intent
d. Context
e. Application
f. ViewGroup

d. Context

Inside any method of an Activity class, the pointer this is referred to as a Context.
An activity is a subclass of Context and it provides a context for the app's UI. The
context is used for creating views, starting activities, and accessing system services.
14.

try{

URL url = new URL(https://pastebin.com/raw/BUXXt7fz);

HttpURLConnection connection = (HttpURLConnection) url.openConnection();

InputStream inputStream = connection.getInputStream();

InputStreamReader inputStreamReader = new BufferedReader(inputStreamReader);

BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

String line = bufferedReader.readLine();

inputStreamReader.close();

inputStream.close();

connection.disconnect();

} catch (MalformedURLException e) {

e.printStackTrace();

} catch(IOException e){

e.printStackTrace();

a. the code doesn’t compile


b. the code triggers a runtime exception
c. a MalformedURLException will be caught by the catch clause
d. the class HttpURLConnection is not used properly

d. the class HttpURLConnection is not used properly

This code is attempting to open a connection to a URL, read the contents of that URL, and
then close the connection. However, there are a few issues with the way the
HttpURLConnection class is being used:
 The HttpURLConnection type is being cast to InputStream, but it should be cast to
InputStreamReader
 The InputStreamReader type is being created using InputStreamReader instead of
InputStream
 BufferedReader is creating using inputStreamReader but it should be created using
new BufferedReader(inputStreamReader)

These issues would cause the code to fail at runtime, and a MalformedURLException would
be caught by the catch clause.

16.

Which mechanisms are presented in the following code:

Public class MainActivity extends Activity{

private Button button;

public static class EvenimClick implements View.OnClickListener{

public void onClick(View view){

//event handling code

public void onCreate(Bundle savedInstanceState){

super.onCreate(savedInstanceState);

button.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v){

//event handling code

}
});

a. using the onClick property of the layout XML file


b. using a dedicated class for implementing the View.OnClickListener interface
c. using an anonymous class for overriding the onClick(View v) method
d. …using the View.OnClickListener interface in an Activity class

b. using a dedicated class for implementing the View.OnClickListener interface c. using an


anonymous class for overriding the onClick(View v) method

In this code, the button click event is handled in two ways:

 b. using a dedicated class EvenimClick for implementing the View.OnClickListener


interface, which is an inner class of the MainActivity class.
 c. using an anonymous class for overriding the onClick(View v) method, inside the
onCreate method of the MainActivity class.

It should be noted that the EvenimClick class is not used in the onCreate method, but it's
there in the code. It should also be noted that this code is missing the initialization of the
button variable, it should be done before setting the click listener.

17.

What is the class used for defining gradients?

a. Paint
b. ColorGradient
c. Gradient
d. Shader
e. Pixel
18.

What is a correct description of an Android activity?

a. A component that has an associated view in the application


b. A component exactly as an event trigger
c. User for managing the building process of an app
d. A class that is used to control the GUI
e. A component of which the description is set in AndroidManifest.xml
f. Just a visual xml component of an android application

19.

What are the true statements about an Android Activity?

a. the activity's UI is stored under res/layout

b. it is used for running background threads

c. it has an associated XML file

d. must be declared in AndroidManifest.xml

e. the associated XML file is stored under res/xml

An Android Activity is a class that represents a single screen in an app. It has an associated
layout file which defines the UI and it is stored under res/layout. The activity must be
declared in the AndroidManifest.xml file so that the system can launch it. It is not used for
running background threads, it is used to interact with the user interface. The associated
XML file is not stored under res/xml, it is stored under res/layout.

20.

Which is the class used for defining gradients?

a. Paint

b. ColorGradient

c. Gradient
d. Shader

e. Pixel

In Android, the class used for defining gradients is the Shader class. The Shader class is the
base class for objects that return horizontal spans of colors during drawing. Shader is used
to fill the color inside shape or give an effect like linear-gradient, radial-gradient, etc. It can
be applied to a Paint object and then used to draw shapes and paths. The other classes such
as Paint, ColorGradient, Gradient, and Pixel are not used for defining gradients.

21.

Which functions from the following list are OS's job?

a. checks the I/O gates

b. manages hardware and software resources

c. file management

d. manages the user interface

e. controls what applications are doing

An operating system (OS) is a software that manages the hardware and software resources
of a computer. The following functions are typically part of an OS's job:

b. manages hardware and software resources: It manages the communication between the
computer's hardware and software, such as allocating memory and processing power to
different programs.

c. file management: It manages the organization and storage of files on the computer's hard
drive, including creating, deleting, and moving files.

a. checks the I/O gates: This task is done by the device driver, which is a software that allows
the operating system to interact with a hardware device.

d. manages the user interface: This task is done by the graphical user interface (GUI) which
is a part of the operating system, but it's not the main responsibility of the OS.

22.

What elements are used for sending data between activities?

a. Bundle class
b. Intent class

c. overloading an operator for sending data

d. onActivityResult() method from the Activity class

e. onSendingData() method from the Application class

In Android, there are several elements that can be used for sending data between activities:

a. Bundle class: Bundle is a mapping from String keys to various Parcelable values. It can be
used to store a set of data as key-value pairs and then passed as an argument to an intent
when starting a new activity.

b. Intent class: An Intent is a messaging object you can use to request an action from
another app component. The Intent class is used to start new activities, and it can carry data
in the form of a Bundle object.

d. onActivityResult() method from the Activity class: This is a method that can be overridden
in an activity to receive a result from another activity that was started with
startActivityForResult() method. The onActivityResult() method will be called by the Android
system when the second activity has finished, and it returns data back to the first activity.

c. overloading an operator for sending data is not a valid android method,

e. onSendingData() method from the Application class is not a valid android method.
23. Which is the Room adnotation used for defining the class associated with a table?

a. @Dao

b. @Entity

c. @Table

d. @View

e. DatabaseTable

In Android, Room is a persistence library that provides an abstraction layer over SQLite. The
@Entity annotation is used to define a class that is associated with a table in the database.
The class is annotated with @Entity and each of its properties is annotated with
@ColumnInfo. The Room will automatically create the table in the database with the same
name as the class, and it will create columns for each of the properties.

The other annotations are used for different purposes:

a. @Dao: used to define data access objects, which are classes that handle database
operations

c. @Table: used to configure the table name and other options associated with the table

d. @View: used to define the views, which are classes that present data from multiple tables

e. DatabaseTable is not an annotation used in android room

24.

Which location can't be used for storing SharedPreferences files?

a. Private storage

b. Cache memory

c. Public storage

d. Internal storage

e. External storage

f. Remote storage

In Android, SharedPreferences is a way to store key-value pairs of data persistently. The files
containing the SharedPreferences data can be stored in different locations depending on
the storage mode selected:
a. Private storage: SharedPreferences files can be stored in the private storage of the app,
which means that they are only accessible by that app.

d. Internal storage: SharedPreferences files can be stored in the internal storage of the
device, which is not accessible by other apps.

e. External storage: SharedPreferences files can be stored in the external storage of the
device, which is accessible by other apps, but the storage should be considered as
removable storage and the file may not be present at all times.

f. Remote storage: SharedPreferences files cannot be stored remotely, it has to be stored on


the device itself.

b. Cache memory: SharedPreferences files should not be stored in the cache memory, as it is
intended for temporary data that can be deleted by the system at any time to free up space.

c. Public storage: Public storage is not a valid location for storing SharedPreferences files.

But SharedPreferences files cannot be stored in remote storage such as a remote server
or cloud storage, because SharedPreferences is a local storage mechanism, it stores data
on the device, and it can't be accessed remotely.

26.

What Android permissions are required for getting the most accurate location using a
location provider?

a. ACCESS_FINE_LOCATION

b. ACCESS_COARSE_LOCATION

c. ACCESS_LOCATION

d. READ_NETWORK_LOCATION

e. ACCESS_NETWORK_LOCATION

a. ACCESS_FINE_LOCATION is required for getting the most accurate location using a


location provider. This permission allows the app to access GPS and network-based location
services. b. ACCESS_COARSE_LOCATION is also required for getting the less accurate
location using a location provider. This permission allows the app to access network-based
location services. It is worth noting that a combination of both Fine and Coarse Location is
also a good practice for location-based apps as it provides the ability to access both GPS and
Network-based location services.
27.

Which of the following scales is recommend being used for Android controls?

a. px (pixels)

b. sp (scale independent pixels)

c. in (inches)

d. dp (density independent pixels)

e. pt (points)

d. dp (density independent pixels) is recommended for Android controls. This scale is based
on the physical density of the screen, so it allows for consistent size across different screen
densities. It's designed to be used in conjunction with the screen density to ensure that
elements are the same physical size on any screen. On the other hand, px (pixels) is based
on the resolution of the screen, so it can vary on different devices with different screen
resolutions. sp (scale independent pixels) is used for font size only. in (inches) and pt
(points) are not recommended for Android controls because they are not density
independent.

28.

For passing an instance of a user defined class between Android components using an Intent
is necessary to:

a. implement Cloneable interface

b. implement Serializable interface? cu serializable a fct el

c. implement Readable interface

d. no need to implement an interface

e. implement Comparable interface

f. implement Parcelable interface?

The Parcelable interface allows an object to be passed as an extra in an Intent. It is more


efficient than Serializable, as it creates a compact binary representation of the object, which
takes less memory and is faster to process. It's worth noting that when implementing
Parcelable interface, it's recommended to use the Parcelable API that Android provides,
which is more efficient than writing custom code to parcel the object.

29.

What method is used to handle a menu item selection in an activity?

a. onOptionsltemSelected()

b. onContextItemSelected()

c. registerForContextMenu()

d. onCreateOptionsMenultem()

e. onOptionsMenultemSelected()

a. onOptionsltemSelected() is the method used to handle a menu item selection in an


activity. It is a callback method that is invoked when the user selects an item from the
options menu or action bar. You can override this method in yoroid ur activity to handle the
selection of a specific menu item.

b. onContextItemSelected() is a method used to handle a context menu item selection. A


context menu is a floating menu that appears when the user performs a long-press gesture
on an element of the UI. c. registerForContextMenu() is a method used to register a view for
a context menu. d. onCreateOptionsMenultem() is a method used to inflate the menu
resource into Menu objects. e. onOptionsMenultemSelected() is not a valid method name in
android.
30.Which are valid types of layouts used for creating user Screens?

a. ScrollView
b. LinearLayout
c. ConstraintLayout
d. TableLayout
e. RelativeLayout
f. TotalLayout
g. GridLayout

31.Which of the following are methods specific to the activity life cycle?

a. onFinish
b. onStart
c. onRun
d. onResume
e. onTerminate
f. onPause
g. onCreate
h. onEnd
i. onDestroy

These are methods that are specific to the activity life cycle in Android, and they are
called at specific points in the life of an activity. onCreate is called when an activity is first
created, onStart is called when an activity becomes visible to the user, onResume is
called when the activity starts interacting with the user, onPause is called when the
activity is no longer visible to the user, onStop is called when the activity is no longer
visible and it's about to be destroyed and onDestroy is called when the activity is
destroyed.

32.What is true about the following line of code:

Intent intent = new Intent(this, ClassName.class) ?

a. It is an implicit intent
b. It is not correct initialized
c. It is an explicit intent
d. Can be used to open a new Activity
e. Can be used to pass data
f. Can include the bundle class

This line of code creates an explicit Intent, which is used to start a new Activity by
specifying the class name of the Activity to be started. The first parameter of the Intent
constructor is the context, in this case "this" refers to the current activity. The second
parameter is the class of the activity you want to open. You can use this intent to pass data
between activities by calling intent.putExtra("key", value) and retrieve the data by calling
getIntent().getExtra("key"). Also, you can include additional data, such as a Bundle, by
calling intent.putExtras(bundle) or intent.getExtras()

33.For the following snippet of code choose the correct statements that are used for
storing the birth date into a SharedPreference file.

Date birthdate = new Date(19,04,1992);

SharedPreferences preferences = getSharedPreferences(“BIRTH_PREF”,


MODE_PRIVATE);

SharedPreferences.Editor editor = preferences.edit();

//Salvare zi de nastere

a. editor.putDate(birthdate);
b. editor.save()
c. editor.commit
d. editor.putString(“BIRTHDATE”, new SimpleDateFormat(“dd-MM-
yyyy”).format(birthdate));
e. editor.apply()

SharedPreferences are used to store key-value pairs of primitive data types. In this case,
the date object cannot be directly stored into a SharedPreference file, so it needs to be
converted to a string format. In this snippet of code, a new SimpleDateFormat object is
created to format the date object into a string with the format "dd-MM-yyyy" and this string
is stored in the SharedPreference file with the key "BIRTHDATE". editor.apply() is used to
apply the changes asynchronously, it commits the changes to the shared preferences file.
a. editor.putDate(birthdate); is not a valid method in SharedPreferences b. editor.save() is
not a valid method in SharedPreferences c. editor.commit is a method that is used to commit
the changes synchronously, it commits the changes to the shared preferences file.

34. For initializing a visual control priorly defined in the xml layout of an activity, which
method should you use:

a. getViewById()

b. findViewById()

c. findViewByName()

d. getViewByName()

e. getControlById()

f. findControlByName()

g. findControlById()

In Android, when you define a visual control (such as a Button, TextView, or


ImageView) in an XML layout file, each control is assigned a unique ID. To initialize and
interact with these controls in your activity's Java code, you can use the method
findViewById(). This method takes an integer parameter, which is the ID of the control you
want to initialize. For example:

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

In this example, my_button is the ID of the button defined in the XML layout, and R.id is a
class that holds the IDs of all controls defined in the XML layout.

a. getViewById() is not a valid method in android. c. findViewByName() is not a valid method


in android. d. getViewByName() is not a valid method in android. e. getControlById() is not a
valid method in android. f. findControlByName() is not a valid method in android. g.
findControlById() is not a valid method in android.

35. Which property sets the distance between the content and the boundaries of a control?

a. size
b. padding (Yes, padding sets the distance between the content and the boundaries of a
control in Android. Padding is the space between the content of a view and its outer
boundary. It can be applied to all four sides of the view, and it can be set in pixels or as a
dimension resource. It can be used to control the space between the content of a view and
its edges, and it can be used to create visual consistency among different views and layouts
in an app.)

c. width

d. height

e. margin (No, margin sets the distance between the boundaries of a control and its
surrounding layout. Margin is the space outside of the view's border. It can be applied to all
four sides of the view, and it can be set in pixels or as a dimension resource. It can be used to
control the spacing between views and the edges of the layout, and it can be used to create
visual consistency among different views and layouts in an app.)

The margin property sets the distance between the content of a control and the
boundaries of the control. It is used to create space around the control, separating it from
other controls or the edges of the screen. Margins can be set individually for each side of the
control (left, right, top, bottom) or all at once. The values of the margins are set in pixels, dp
(density-independent pixels), sp (scaled pixels), or other units.

a. size: it's not a property that sets the distance between the content and the boundaries of
a control. b. padding: it's the space between the content and the border of the control, it's
similar to margins but it's inside the control. c. width: it's the width of the control. d. height:
it's the height of the control.

36. Which of the following storage classes are valid in an SQLite database?

a. INTEGER

b. TEXT

c. NULL

d. DATETIME

e. STRING

f. BOOLEAN
g. REAL

h. BLOB

INTEGER, is used to store signed integers (whole numbers) TEXT, is used to store text
strings NULL, is used to store null values REAL, is used to store floating-point numbers
(decimal values) BLOB, is used to store binary data (images, audio, or other files)

37.What is the meaning of a SoC architecture?

System on a Chip

38. Which building management tools can be used implicitly (by default) in Android?

a. Gradle

b. Ant

c. MSBuild

d. CMake

e. Maven

Gradle is the default building management tool used in Android for building and
managing projects. It is a powerful and flexible build tool that uses a Groovy-based domain-
specific language (DSL) to define build scripts. Gradle is able to handle complex
dependencies and provides advanced features such as multi-project builds, incremental
builds, and build caching. It can be used to automate the building, testing, and deployment
of Android applications. Gradle is integrated with Android Studio, the official IDE for Android
development, and it is the recommended tool for building and managing Android projects.

39.What is the role of a Handler used in asynchronous operation?

a. manages messages sent between threads

b. knows how to handle runnable objects

c. used for processing resources based on their unique identifier

d. posts messages into the MessageQueue

e. block messages coming from a specific thread


f. interacts with the Looper class to dispatch messages

In Android, a Handler is used to manage messages sent between threads. It allows


communication between different threads by passing messages between them. The
messages are passed through a MessageQueue, which is a data structure that holds the
messages waiting to be processed.

The handler has a reference to the Looper class, which is an object that runs in the
background and dispatches messages to the appropriate thread. The Looper checks the
message queue for new messages and sends them to the handler for processing.

A handler can post messages into the MessageQueue, these messages can contain a
Runnable object, which will be executed by the thread the Looper is associated with.

b. knows how to handle runnable objects: The handler doesn't "know" how to handle
runnable objects, but it can post them to the MessageQueue for execution c. used for
processing resources based on their unique identifier: A handler is not responsible for
processing resources based on their unique identifier. e. block messages coming from a
specific thread: A handler can't block messages coming from a specific thread, but it can
remove messages from the queue or process them in a specific way based on the type or the
sender of the message.

40. What collor pallet is used for setting transparency?

ARGB

41. What other controls can be used to simulate the behaviour of a RadioButton in a
RadioGroup?

a. Switch

b. Chip

c. Button

d. ToggleButton

e. CheckBox

In Android, a RadioGroup is a container for a set of RadioButton controls, which are


used to provide a single selection from a group of options. However, other controls such as
ToggleButton and CheckBox can also be used to simulate the behavior of a RadioButton in a
RadioGroup.
A ToggleButton is a two-state button that can be used to represent a binary choice. It
can be used to simulate the behavior of a RadioButton by using only two options, one for the
"on" state and one for the "off" state.

A CheckBox is also a binary choice control, but it can be used to simulate the
behavior of a RadioButton by using only one CheckBox per option and clear the selection on
the other options when one is selected.

A Switch is not commonly used to simulate the behavior of a RadioButton in a


RadioGroup, it's more similar to a ToggleButton but with a different visual representation. A
Chip is a visual element that represents a complex entity in a compact form, it's not
commonly used to simulate the behavior of a RadioButton in a RadioGroup. A Button is a
simple push button that can be used to initiate an action, it's not commonly used to simulate
the behavior of a RadioButton in a RadioGroup.

42. Which is a valid BaseAdapter method that can be overridden?

a. getCount()

b. getItem()

c. getItemId()

d. getRow()

e. getView()

f. getItemPosition()

g. getPosition()

BaseAdapter is an abstract class that serves as the base class for adapters that can
be used in ListViews, GridViews, and Spinner controls. It provides a basic implementation of
some common methods that need to be overridden by the subclass.

getCount() is a method that returns the number of items in the adapter. It is used to
determine the number of items to be displayed in the list.

getItem(int position) is a method that returns the data item associated with the specified
position in the data set.
getItemId(int position) is a method that returns the row id associated with the specified
position in the list.

getView(int position, View convertView, ViewGroup parent) is a method that returns a view
that represents an item in the data set. It is used to create and bind views to the data.

d. getRow() is not a valid method of BaseAdapter f. getItemPosition() is not a valid method


of BaseAdapter g. getPosition() is not a valid method of BaseAdapter

43. What is the role of an Android adapter? (asta e putin cu semnul intrebarii)

a. To control how the data is handled by the user


b. To mitigate the interaction between date source and controls
c. To bind the control of the data source
d. To bind the control TO the data source
e. To behave as an adapter between the data and the UI
f. To create a view for each item in the collection
g. To manage items inside data collections

An android adapter's role is to bridge the data and the UI, it behaves as an adapter
between the data and the UI. It creates a view for each item in the collection, manages
items inside data collections and mitigates the interaction between the data source and
controls by handling the data and creating the views that are displayed in the controls.

c. To bind the control of the data source: An adapter's role is to bind the data source to
the controls, not to control the data source.

a. To control how the data is handled by the user: An adapter's role is to provide data to
the UI, not to control how the user handles the data.

44. What are the valid map types in Google Maps?

a. Satellite

b. Normal

c. Terrain

d. Hybrid

e. Panoramic

f. Native
g. Road

Instead of Normal there can also be RoadMap which is correct as well

45. Which type of control can be used in conjunction with an adapter?

a. Spinner

b. WebView

c. ListView

d. AutoCompleteTextView

e. ToggleButton

f. GridView

g. ImageButton

An adapter can be used in conjunction with several types of controls in Android, some of
them are:

 Spinner: A spinner is a drop-down list that allows users to select an item from a list. It
uses an adapter to bind the data to the spinner.
 ListView: A list view is a vertically scrolling list of items. It uses an adapter to bind the
data to the list view.
 AutoCompleteTextView: An AutoCompleteTextView is an editable text view that
shows a list of suggestions based on the characters that the user types. It uses an
adapter to bind the data to the suggestions list.
 GridView: A GridView is a view group that displays items in a two-dimensional,
scrollable grid. It uses an adapter to bind the data to the grid view.

b. WebView is a control that is used to display web pages, it's not commonly used in
conjunction with an adapter e. ToggleButton is a control that is used to represent a binary
choice, it's not commonly used in conjunction with an adapter g. ImageButton is a control
that is used to display a button with an image, it's not commonly used in conjunction with an
adapter
47.

try {

URL url = new URL (https://pastebin.com/rawBUXXu7fz);

HttpURLConnection connection = (HttpURLConnection) url.openConnection();

InputStream inputStream = connection.getInputStream();

InputStreamReader inputStreamReader = new InputStreamReader(inputStream);

BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

String line = bufferedReader.readLine();

bufferedReader.close();

inputStreamReader.close();

inputStream.close();

connection.disconnect();

} catch (MalformedURLException e) {

e.prinStackTrace();

} catch (IOException e) {

e.printStackTrace();

a) The code doesn’t compile


b) The code triggers a runtime exception
c) A MalformedURLException will be caught by the catch clause
d) The class HttpUrlConnection is not used properly

a) The code doesn’t compile: This is correct because there are several syntax errors in
the code. The URL constructor takes a string argument, but the string is not enclosed
in quotation marks. Also, the printStackTrace() method is misspelled and the last '}' is
not needed.
b) The code triggers a runtime exception: This is not correct because the code is not
functional due to the syntax errors mentioned in option a. It will not run to trigger
any exception.

c) A MalformedURLException will be caught by the catch clause: This is correct because


the MalformedURLException is thrown when a string is not a properly formatted URL
and the catch block will handle this exception.
d) The class HttpUrlConnection is not used properly: This is not correct. The class
HttpURLConnection is used correctly, it is instantiated by casting the result of the
openConnection() method on a URL object, and then the getInputStream() method is
called on it to get the InputStream from the resource located at the URL.

48. Which is the first method called when instantiating an Activity?

a) onInit
b) onCreate
c) onTrigger
d) onStart
e) onInitialization
f) onBuild

b) onCreate

The first method called when instantiating an Activity is onCreate(). This method is called
when the activity is first created and is responsible for initializing the activity and setting up
the user interface. It is also where you can inflate your layout, set up any views, and perform
any other initialization tasks that need to be done when the activity is first created.

The others options are wrong because they are not actual methods that are part of the
Android Activity lifecycle.

 "onInit" , "onTrigger", "onInitialization", "onBuild" are not exist in the Android


Activity lifecycle.
 "onStart" is a method that is called after onCreate() and onResume(). It is where you
can begin interacting with the user, such as setting up a location listener or starting a
animation.

So onCreate() is the first method that is called when instantiating an Activity.


51.What method is used to save changes in fragment transactions?

a) commit
b) execute
c) replace
d) add

a) commit

When making changes to fragments in a FragmentTransaction, you need to use the


commit() method to save the changes. The commit() method schedules the changes to
be committed, which will happen when the main thread is next idle.

The other options you mentioned are methods that are part of the FragmentTransaction
class but they're not used for saving changes:

execute: Not exist in FragmentTransaction

replace: Replaces an existing fragment that was added to a container.

add: Adds a fragment to the activity state.

So the correct method for saving changes in fragment transactions is commit.

52. What property is necessary to be updated when upgrading the structure of a database?

a) iteration
b) level
c) stage
d) version
e) number

d) version

When upgrading the structure of a database, it is necessary to update the version property
of the database. This property, usually an integer, is used by the database management
system to keep track of the current schema version. When the database is opened and the
version number stored in the database does not match the version number of the
application, the database management system will know to run the necessary migration
code to upgrade the database to the new schema.
The other options you mentioned are not associated with upgrading the structure of a
database:

iteration: Not used to refer to the current version of a database

level: Not used to refer to the current version of a database

stage: Not used to refer to the current version of a database

number: Not used to refer to the current version of a database

So the correct property that is necessary to be updated when upgrading the structure of a
database is version.

53. Which of the following methods could be called when an activity goes in the
background?

a) onPause()
b) onDestroy()
c) onStop()
d) onFinish()
e) onResume()
f) onCreate()
g) onStart()

a) onPause()

c) onStop()

When an activity goes in the background, the system calls the onPause() and onStop()
methods.

onPause() is called when the activity is no longer in the foreground and it is used to release
resources and stop animations and other things that are consuming CPU. This method is also
used to save the current state of the activity if it is likely to be destroyed.

onStop() is called when the activity is no longer visible on the screen and it is used to release
resources that are not needed while the activity is not visible.

The other options you mentioned are methods that are part of the Android Activity lifecycle,
but they are not called when an activity goes in the background:
b) onDestroy(): This method is called before the activity is destroyed.

d) onFinish(): Not exist as a method in Android framework

e) onResume(): This method is called when the activity comes to the foreground

f) onCreate(): This method is called when the activity is first created.

g) onStart(): This method is called after onCreate() or onRestart() and before onResume().

54. What is the native code for the Android OS?

a) Kotlin
b) Swift
c) Objective-C
d) Scala
e) Python
f) Java
g) C/C++

The native code for the Android OS is written primarily in C and C++.

Android is a mobile operating system that is based on the Linux kernel. The Android
operating system is written in a combination of languages, including C and C++ for the core
system and Java for the application framework. The C and C++ code is responsible for the
low-level operations of the system, such as memory management, process management,
and device drivers. The Java code, on the other hand, provides the framework for
developing Android applications and interacts with the C and C++ code through the Java
Native Interface (JNI). This allows Java code to call C and C++ code and vice versa, providing
a powerful and flexible development environment for Android apps.

57) For the following snippet of code choose the correct statement that allows user to
update the content of the listView as he adds new objects to the collection.

//listView and students are considered to be correctly initialized and declared

@Override

Protected void onCreate(Bundle savedInstanceState){


Super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

listView = findViewById(R.id.lv_students);

ArrayAdapter<Student> adapter = new ArrayAdapter<>(

getApplicationContext(), android.R.layout.simple_list_item_1, students) ;

listView.setAdapter(adapter) ;

students.add(new Student()) ;

a) listView.notify();
b) adapter.notify();
c) adapter.notifyDataSetChanged()
d) listView.notifyDataSetChanged() (LA FEL CA LA CEALALTA DE MAI SUS NU STIU DACA
RASPUNSUL ASTA E CORECT SAU NU, NU SE VEDE IN POZA)

The ArrayAdapter class has a method called "notifyDataSetChanged()" which updates the
listView when the data in the adapter has been changed. It will update the ListView to
reflect the new data in the adapter, this include adding new data to the adapter, removing
data from the adapter, or changing the data in the adapter. In this case, when adding new
Student to the students list, the call of adapter.notifyDataSetChanged() will update the
ListView to show the new Student.

It's important to note that the notify() method does not exist in the ListView or the
ArrayAdapter class, and calling it will cause a compile error. The
listView.notifyDataSetChanged() method is not the correct statement, it only
notifyDataSetChanged() method is a member of ArrayAdapter class.

60) What property is used for centering the control inside the parent?

a) android:layout_gravity

b) android:layout_allign

c) android:layout_float

d) android:layout_center
e) android:layout_middle

The layout_gravity attribute is used to specify how a child view should position itself within
its parent. By setting the value of layout_gravity to "center", the child view will be centered
within its parent.

It can be used on layouts like LinearLayout, FrameLayout, and RelativeLayout.

android:layout_align is used to align two views with respect to each other.


android:layout_float is not a valid attribute android:layout_center and
android:layout_middle are not valid attributes.

61) What is a correct statement about the R.java class in an Android project:

a) can be created by the user to include Android components

b) can be created by the user to include resources

c) it is used to access different sets of resources

d) R.java class does not exist

e) R.java class is not mandatory

f) is a generated source file with resource identifiers

g) is a generated source file with Android components

The R.java file is a generated source file that contains resource identifiers for all the
resources in your project. It is created by the Android build system and is used to access
different sets of resources, such as strings, images, layouts, and more. It is created
automatically by the Android build system and should not be edited manually. The file is
located in the gen folder of your project and is used by the Android operating system to
access the resources needed by your app. The R class contains static constant values for
each type of resource, such as layouts, strings, and colors. These constant values can be
used in your Java code to reference resources, rather than hard-coding their values. The
R.java file is mandatory and it is created automatically, it is not necessary to create it
manually.

62) The control used for selecting a value from a given interval is?

a) ProgressBar
b) Slider

c) ActionBar

d) SeekBar

e) SelectBar

f) Button

A SeekBar is a control used for selecting a value from a given interval. It is similar to a Slider,
but it allows the user to interact with the control by dragging a thumb along the track to set
the value. It can be used for tasks such as adjusting the volume on a media player, adjusting
the brightness of a screen, or adjusting the speed of a video. It is often used in conjunction
with a ProgressBar, which displays the current value of the SeekBar to the user.

63) The code sequence found inside the <intent-filter> tag will:

<activity android: name=”.MainActivity2”>

<intent-filter>

<action android :name=”android.intent.action.MAIN” />

<category android :name= “android.intent.category.LAUNCHER” />

</intent-filter>

</activity>

a) filter the content send by the activity when using Intent objects

b) filter the activity based on a predefined criteria

c) will trigger runtime exceptions

d) other results not specified here

e) launching an activity when opening the app

The code sequence found inside the <intent-filter> tag is used to specify the intent filter for
the activity, in this case MainActivity2. The intent filter defines the type of intents that an
activity, service, or broadcast receiver can respond to. In this case the action
android.intent.action.MAIN indicates that this activity serves as the entry point for the
application. And the category android.intent.category.LAUNCHER indicates that this activity
should be listed in the app launcher, so when the app is open, this MainActivity2 will be
launched.

1. Which of the following sotrage classes are not valid in SQLite?


- STRING
- DATETIME
- BOOLEAN

2. Not valid map types:


- Native

3. In metoda setARGB(a,r,g,b) din clasa Paint, parametrul a de tip int reprezinta:


- Nivelul de transparenta
4. Which is not a valid BaseAdapter method that can be overridden?
- getPosition()

5. Clasa care nu extinde BaseAdapter este:


- ListAdapter

6. Metoda getView() din clasa BaseAdapter returneaza:


- Obiectul de tip View pentru afisare in lista

7. Metoda getItem() din clasa BaseAdapter returneaza:


- elementul de pe o anumita pozitie din lista primita

8. Includerea de elemente cu imagini asociate intr-un control de tip lista (Spinner, ListView etc)
se realizaeaza prin intermediul unui adaptor:
- Personalizat(CustomAdapter)

9. Care dintre următoarele adaptoare sunt predefinte în Android?


- ArrayAdapter
- SimpleCursorAdapter

10. Which are the wrong intent actions, NOT used for dialing a phone number?
- ACTION-ANSWER
- ACTION-RING
- ACTION-PHONE

11. Pt accesul la retea este necesara includerea permisiunii:


-INTERNET

12. Pentru afișarea unei activități se apelează metoda …. Din clasa Context
- startActivity()
13. Pentru lucru dynamic cu argumente, in fisierul layout, containerul asociat va fi de tip:
- Fragment

14. What methods needs to be called to be sure that changes you made in a SQLite db will be
saved?
- SQLiteDatabase.setTransactionsSuccesful()

15. What is an android decision?


- An Android process that runs in the background,
- A specialized Android software component that doesn’t have a GUI

16. What statements are true about SharedPreferencesAndroid obj?


- It is using SharedPreferencesEditor to add values
- It is saved in the persistent internal memory
- It needs to call commit() at the end to save values

17. Care este ordinea de apel a metodelor din ciclul de viată al activităților?
- onCreate() -> onStart() -> onResume() -> onPause() -> onStop() -> onDestroy()

18. Android are o interfață programabilă în


- Java

19. Android
- Este bazat pe kernelul de Linux

20. Arhitectura Android este formata din:


- Framework, Aplicatii, Android Runtime, Biblioteci, Linux Kernel

21. Care dintre urmatoarele nu reprezinta o caracteristica a dispozitivelor mobile:


- Grafica

22. Care sunt caracteristicile dispozitivelor mobile?


- Portabilitatea, accesibilitatea, utilizabilitatea și performanța

23. Ce semnifica ANR


- Application Not Responding

24. Afirmatia "Arhitectura Android este bazata pe o stiva de componente" este:


- Adevarata

25. Afirmatiile: "Scripturile Gradle sunt NU folosite pentru build automat" si"Există câte un fișier
gradle pentru fiecare modul" sunt:
- Prima falsa si a doua adevarata

26. Alegeti afirmatia corecta despre drawable:


- Contine diferite tipuri de imagini
27. Alegeti afirmatia corecta despre layout:
- Conține toate fișierele XML care definesc interfața

28. Alegeti afirmatia corecta despre mipmap:


- Conține logo-ul aplicației și conține iconițele în diferite formate pentru dispozitive diferite;

29. Android Studio acceptă limbaje precum:


- Java, C, C++, Kotlin

30. Android Studio:


- Este un sistem de dezvoltare bazat pe Gradle

31. Cum stabilim cu ce activitate porneste aplicatia?


- In fisierul AndroidManifest

32. Permisiunile, metadata si activitatile din cadrul aplicatiei se regasesc in:


- In fisierul AndroidManifest
33. Activitatea startActivityforResult() este pornita in mod
- Dependent

34. Activitatile desfasurate intre onCreate() si onDestroy sunt de tipul:


- Entire lifetime

35. Activitatile desfasurate intre onResume() și onPause() sunt de tipul:


- Foreground lifetime

36. Activitatile desfasurate intre onStart() și onStop() sunt de tipul:


- Visible lifetime

37. Adăugarea de informații se face prin:


- putExtra(key,value)

38. Care dintre urmatoarele metode este gresita:


- putStringExtra()

39. Comunicarea prin intermediul obiectelor de tip intent nu se face intre:


- Diferite clase

87. Înainte de a distruge activitatea curentă trebuie


- setat și codul rezultat, astfel încât în activitatea apelatoare să știm dacă utilizatorul a realizat
sau nu modificările necesare.

88. INTENT este format din:


- Explicit și implicit

89. O activitate nu poate fi in starea de:


- Inactive
90. Pentru a transmite un bundle folosim:
- putExtras()

91. Apelul și pornirea procesări pe firul secundar de execuție se face prin intermediul metodei:
- Execute(params)

92. AsyncTask trebuie să fie utilizat pentru operații:


- Scurte

93. Care metodă din clasa AsyncTask rulează pe firul secundar de execuție:
- doInBackround()

94. Parametrii sunt trimiși de la firul principal către firul secundar in cadrul metodei

- doInBackround()

95. Fiecărui fir de execuție i se asociază:


- o secvență de instrucțiuni, un set de registri CPU și o stivă

96. Folosim EXECUTORS deoarece:


- metoda prin AsynckTask este vulnerabilă

97. Pentru selectia unui element dintr-un control de tip Spinner se implementeaza
metoda______ din interafta specifica:
- onItemSelected()

98. Initializarea unui obiect de tip HttpConnection se realizeaza:


- prin intermediul metodei openConnection() din clasa URL

99. Initializarea unui obiect din fisierul JSON se realizeaza cu ajutorul metodei:
- getJSONObject()

100. Care este coloana care trebuie selectata cand se utilizeaza un obiect de tipul
SimpleCursorAdapter?
- _id

101. Obiectele de tip Canvas sunt disponibile:


- ca parametru in metoda onDraw() din clasa View sau associate unui obiect de tip Bitmap

102. La utilizarea Firebase Realtime Database intr-o aplicatie Android, initializarea si referirea
bazei de date se realizeaza prin intermediu clasei:
- FirebaseDatabase

103. Platforma Firebase pune la dispozitie urmatoarele baze de date, ce pot fi utilizate in
aplicatiile mobile:
- Realtime Database ?i Cloud Storage

104. Aplicațiile Android sunt:


- Aplicatii Java incompatibile Java SE

105. Ce metode trebuie apelate in AddExpenseActivity?

- intent.putExtra(EXPENSE_KEY,object)
- setResult(RESULT_OK, intent)
- intent = getIntent()

1. Pentru afișarea unui mesaj de informare pentru o durata nedeterminata NU se utilizează clasa:
- Toast

2. Afișarea paginilor HTML in cadrul unei aplicațiise realizeazăprinintermediul controlului:


- WebView

3. Serviciile:
- ruleaza in paralel cu firul principal de executie si nu au interfata grafica

4. Clasa FragmentTransaction este responsabila cu:


- operatii cu fragmente

5. Pentrudeschidereaunei aplicațiide vizualizarea fișierelorPDFse inițializeazăunobiectde tip Intent


cu acțiunea
- ACTION_VIEW

6. Selectia unui Contact prin intermediul unui obiect de tip Intent se realizeaza prin intermediul
actiunii:
ACTION_PICK

7. Directorul permite includerea oricărui tip de fișiersi referirea acestuia prin intermediul unui
identificator deresursa:
- res/raw

8. Din cod, accesulla resursele de tipstring(res/values)se realizeazăprinmetoda din clasa


- getString()

9. Care este formatul unui fișier SharedPreferences?


- XML

10. La prelucrarea fișierelor XML prin intermediul bibliotecii XML Pull:


- evenimentele sunt tratate imediat

11. In directorul , asociat pachetului aplicației,fișierele pot fi organizate in directoare:


- assets

12. ParametriigenericiaiclaseiAsyncTask&it;param1,param2,param3>seregăsesccatipuride date (in


aceeași ordine) in metodele:
- doInBackground(), onProgressUpdate() și onPostExecute()

13. . Pentru afișarea unei opțiunidemeniu in bara de acțiune(ActionBar)se utilizează:


- atributul showAsAction cu valoarea always

14. O activitate este parțial vizibila după apelul metodei:


onPause()

15. Uzual,pentruafișareauneisingure componentevizuale la unmoment datse utilizează containerul


FrameLayout

16. Pentru afișarea unei opțiunidemeniu in bara de acțiune(ActionBar)se utilizează:


atributul showAsAction cu valoarea always

17. Specific prelucrării fișierelor XML prin DOM este:


Se genereaza o structura ierarhica in memorie

18. Pentru stocarea persistenta a datelor de forma&It;cheie, valoare>se utilizeazăobiecte dedicate


de tipul:
SharedPreferences

You might also like