In Android 8.0, API level 26, some APIs regarding notification behaviors were moved from Notification to NotificationChannel. For example, what should we use instead of NotificationCompat.Builder.setPriority() for Android 8.0 and higher?
A. NotificationChannel.setPriority()
B. NotificationChannel.setImportance()
C. NotificationCompat.Builder.setImportance()
What do you want from Room when you create a DAO method and annotate it with @Delete?
Example:
@Dao
public interface MyDao {
@Delete
public void deleteUsers(User... users);}
A. Room generates an implementation that inserts all parameters into the database in a single transaction.
B. Room modifies a set of entities, given as parameters, in the database. It uses a query that matches against the primary key of each entity.
C. Room removes a set of entities, given as parameters, from the database. It uses the primary keys to find the entities to delete.
What do you want from Room when you create a DAO method and annotate it with @Update?
Example:
@Dao
public interface MyDao {
@Update
public void updateUsers(User... users);}
A. Room generates an implementation that inserts all parameters into the database in a single transaction.
B. Room modifies a set of entities, given as parameters, in the database. It uses a query that matches against the primary key of each entity.
C. Room removes a set of entities, given as parameters, from the database. It uses the primary keys to find the entities to delete.
What happens when you create a DAO method and annotate it with @Insert?
Example:
@Dao
public interface MyDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
public void insertUsers(User... users);}
A. Room generates an implementation that inserts all parameters into the database in a single transaction.
B. Room modifies a set of entities, given as parameters, in the database. It uses a query that matches against the primary key of each entity.
C. Room removes a set of entities, given as parameters, from the database. It uses the primary keys to find the entities to delete.
What is demonstrated by the code below?
// RawDao.java@Daointerface RawDao {
@RawQuery
User getUserViaQuery(SupportSQLiteQuery query);}
// Usage of RawDao
...
SimpleSQLiteQuery query =
new SimpleSQLiteQuery("SELECT * FROM User WHERE id = ? LIMIT 1",
new Object[]{userId});User user = rawDao.getUserViaQuery(query); ...
A. A method in a Dao annotated class as a raw query method where you can pass the query as a SupportSQLiteQuery.
B. A method in a Dao annotated class as a query method.
C. A method in a RoomDatabase class as a query method.
An example. In our ViewModelFactory(that implements ViewModelProvider.Factory) we have an instance of our Repository, named mRepository. Our ViewModel has such constructor:
public MyViewModel(MyRepository myRepository)...
Next, in our ViewModelFactory create ViewModel method (overriden) looks like this:
@NonNull @Override public
try {
//MISSED RETURN VALUE HERE
} catch (InstantiationException | IllegalAccessException |
NoSuchMethodException | InvocationTargetException e) {
throw new RuntimeException("Cannot create an instance of " + modelClass, e);
}
}
What should we write instead of “//MISSED RETURN VALUE HERE”?
A. return modelClass.getConstructor().newInstance(mRepository);
B. return modelClass.getConstructor(MyRepository.class).newInstance();
C. return modelClass.getConstructor(MyRepository.class).newInstance(mRepository);
For example, we have a file in our assets folder app/src/main/assets/sample_teas.json. To get an InputStream for reading it, from out Context context, we can try doing this:
A. InputStream input = context.getResources().openRawResource (R.raw.sample_teas);
B. InputStream input = context.getAssets().open("sample_teas.json");
C. InputStream input = context.getResources().getAssets().open ("sample_teas.json");
For example, we have a BufferedReader reader, associated with the json file through InputStreamReader. To get a file data we can do this:
A. String line;try {while ((line = reader.readLine()) != null) {
builder.append(line);
}
JSONObject json = new JSONObject(builder.toString());
return json;
} catch (IOException | JSONException exception) {
exception.printStackTrace();
}
B. JSONObject line;try {while ((line = reader.readJSONObject ()) != null) {
builder.append(line);
}
JSONObject json = new JSONObject(builder.toString());
return json;
} catch (IOException | JSONException exception) {
exception.printStackTrace();
}
C. String line;try {while ((line = reader.readLine()) != null) {
builder.append(line);
}
JSONObject json = new JSONObject(builder.toString());
return json;
} catch (RuntimeException|ArrayIndexOutOfBoundsException exception) {
exception.printStackTrace();
}
For example, we have a file in our raw folder app/src/main/res/raw/sample_teas.json. To get an InputStream for reading it, from out Context context, we can do this:
A. InputStream input = context.openRawResource(R.raw.sample_teas);
B. InputStream input = context.getRawResource(R.raw.sample_teas);
C. InputStream input = context.getResources().openRawResource (R.raw.sample_teas);
For example, our preferences.xmlfile was added by addPreferencesFromResource(R.xml.preferences). Our preferences.xmlfile contains such item:
In our Fragment, we can dynamically get current notification preference value in this way:
A. String sortBy = PreferenceManager.getDefaultSharedPreferences(getContext()).getString(getContext().getString(R.string.pref_sort_key),getContext().getResources().getBoolean(R.bool.pref_default_sort_value)
);
B. String sortBy = PreferenceManager.getSharedPreferences(getContext()).getString(getContext().getString(R.string.pref_default_sort_value),getContext().getString(R.string.pref_sort_key)
);
C. boolean sortBy = PreferenceManager.getSharedPreferences(getContext()).getBoolean(getContext().getResources().getBoolean(R.bool.pref_default_sort_value),getContext().getString(R.string.pref_sort_key)
);
D. String sortBy = PreferenceManager.getDefaultSharedPreferences(getContext()).getString(getContext().getString(R.string.pref_sort_key),getContext().getString(R.string.pref_default_sort_value)
)
Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only Google exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your ASSOCIATE-ANDROID-DEVELOPER exam preparations and Google certification application, do not hesitate to visit our Vcedump.com to find your solutions here.