This MOOC teaches you how to program core features and classes from the Java programming language that are used in Android, which is the dominant platform for developing and deploying mobile device apps.
In particular, this MOOC covers key Java programming language features that control the flow of execution through an app (such as Java’s various looping constructs and conditional statements), enable access to structured data (such as Java’s built-in arrays and common classes in the Java Collections Framework, such as ArrayList and HashMap), group related operations and data into classes and interfaces (such as Java’s primitive and user-defined types, fields, methods, generic parameters, and exceptions), customize the behavior of existing classes via inheritance and polymorphism (such as subclassing and overriding virtual methods).
Enroll on Coursera
Q1. Which of the following are key concepts found in all object-oriented programming languages, according to the lessons in this module?
Q2. Which of the following are examples of data abstraction features supported by Java, according to the lessons in this module?
Q3. Which of the following is the best definition of an “abstract data type” (ADT), according to the lessons in this module?
Q4. Which of the following are accurate descriptions of differences between Java classes and interfaces, according to the lessons in this module?
Q5. Which of the following are benefits of Java generics, according to the lessons in this module?
Q6. Which of the following are benefits of inheritance in Java, according to the lessons in this module?
Q7. Which of the following describe the purpose of exception handling in Java, according to the lessons in this module?
Q8. Which of the following describe the purpose of polymorphism in Java, according to the lessons in this module?
Q9. Which of the following are expectations of learners who take this MOOC, according to the lessons in this module?
Q10. Which of the following are recommended strategies for learning the material covered in this MOOC, according to the lessons in this module?
Q1. What version of the Android API are we going to use in this class?
Q2. Which Android Studio wizard button will you use to -Open- an existing project?
Q3. There is a folder in Android Studio projects called ‘res’. What does ‘res’ mean?
Q4. By convention which of these names is in proper formatting for a Java class?
Q5. Bugs(defects) in software can be categorized into two main groups. Which of these match those categories?
Q6. In Android Studio what does a word having a red squiggly line under it likely mean?
Q7. Which of the following is not a step in running our code in the supplied Android app?
Q8. To submit your solution to the auto-grader so that you can receive a grade…
Q1. What is the value of this expression:
54 % 10 + 6 * 3 % 4
Q2. Which operator in the following expression will be evaluated first?
2 / (1.0 + 2 * 3) – 2
Q3. Overloading is a feature that allows the creation of two or more methods with the same name as long as the parameter lists are different.
Q4. Given a String object called str, the statement str.toUpperCase(); will change the object to have all uppercase letters:
Q5. The following string is a legal Java identifier that could be used as a variable name or a method name: _am_I_okay
Q6. The programmer can manually change data values from one type to another type by an operation called a type-_
Q7. What is the output produced by running the program below? Read the code carefully before selecting the correct answer.
1234567891011
public void process() {
int x = 22;
out.print(x + ” “);
modify_x(x);
out.print(x + ” “);
}
public static void modify_x (int x) {
x = 99;
out.print(x + ” “);
Q8. Given variable x of type double, which of the following result in a different value being assigned to x?
Q9. The following code always prints the value 9:
12
int x = 8;
out.println(x++);
Q10. When calling a method, the name of the actual argument (at the call site) must match the name of the formal parameter used in the method’s parameter list.
Q11. What reserved word is used to indicate that a method does not return a value?
Q12. A bit can have __ different values.
Q1. What is the truth value of the following expression?
(-8 >= 9) || (14 > 2)
Q2. What is the truth value of the following expression?
(5 > 0) && (7 > 0)
Q3. What is the truth value of the following expression?
(8 != 7) && (4 > 4)
Q4. What is the truth value of the following expression?
!(8 >= 2*3) || (7 >= 11)
Q5. What is the output for the following code segment?
123456
int x = 10;
int y = 27;
if (x > y){
x = x + y;
}
Out.print(x);
Q6. What is the output of the following code?
12345678910111213
int age = 23;
if (age >= 55){
Out.println(“Your cost is discounted by 10%”);
}
if (age >= 21){
Out.println(“You can purchase a wristband for $10”);
}
if (age >= 16){
Out.println(“Your cost is discounted by 15%”);
}
Q7. What is the output of the following code?
1234567891011
int x = -7;
if(x > 0){
Out.println(x + 10);
}
else if (x == 0){
Out.println(x);
}
else{
Out.println(x – 10);
3
Q8. What value of x would produce the desired output seen below?
12345678910
if (x > 10){
Out.println(“Above average”);
if (x > 20){
Out.println(“Should continue with the program”);
else {
Out.println(“May want to continue with the program”);
}
else{
Out.println(“Do not continue, move to another section”);
}
Desired output:
12
Above average
May want to continue with the program
Q1. Given the following loop:
123 for (int i = 1; i < 5; i = i+1) {
out.println(“Hello world!”); }
How many lines of output will be printed?
Q2. Given the following loop:
123 for (int i = 5; i >= 0; i–) {
out.println(“Hello world!”); }
How many lines of output will be printed?
Q3. Given the following loop:
12345 for (int i = 1; i <= 5; i++) {
for (i = 1; i <= 3; i++) {
out.println(“Hello world!”);} }
How many lines of output will be printed?
Q4. Given the following loop:
12345 for (int i = 1; i <= 5; i++) {
for (int j = 1; j < i; j++) {
out.println(“Hello world!”);} }
How many lines of output will be printed?
Q5. Fill in the blank of the following loop so that 10 lines of output are printed:
123 for (int i = _ ; i <= 15; i++) {
out.println(“Hello world!”); }
Preview will appear here…
6
Q6. Given the following loop:
123456 for (int i = 1; i <= 5; i++) { for (int j = 1; j > i; j++) {
out.print(“*”);}
out.println(); }
How many stars will be printed in total?
Q7. Given the following loop:
123 for (int i = 1; i <= 8; i++) {
out.print(_ + ” “); }
What expression would you put in the print statement to produce the following sequence as output:
1
57 46 35 24 13 2 -9 -20
Please specify your answer in the form: ai+b or ai-b, where a & b are replaced by integer constants. For example, a correctly specified answer would look like this: 5i-8 or this: -4i+6
Do not use parentheses or spaces in your answer.
8*i-3
Q8. Fill in the blank of the following loops so that the following pattern is printed:
123456
123456789
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= i-1; j++) {
out.print(” “);
}
for (int j = 1; j <= __; j++) {
out.print(““); } out.println(); } Please specify your answer in the form: ai+b or ai-b, where a & b are replaced by integer constants. For example, a correctly specified answer would look like this: 5i-8 or this: -4*i+6
Do not use parentheses or spaces in your answer.
-2*i+11
Q1. Consider the following code:
123456
int i = 17;
int x = 4;
while (i>x){
i = i-3;
out.print(i + ” “); } What is the output of this code?
Q2. Consider the code
123456
int i = 23;
int n = 25;
do{ out.print(i + ” “); }while (i < n); i = i-5;
What will the output of this code be?
Q3. Given the code
12345 int i = 10;
while (i > 0){
out.print(i + ” “);
i = i-2; }
Which for loop would produce the same results?
Q4. Suppose every player in your game is faced with the task of “rolling” a set of dice to determine what tools they can take with them on their next adventure. Some of the outcomes of the roll are positive (earn a “Bonus” tool etc.) while some are negative (lose all currently held tools, etc.). Every player must roll at least once, but may choose to roll as often as they like by purchasing extra rolls. Which loop construct and accompanying explanation best describe a good coding choice?
Q5. Consider the code
12345
int i = 1;
while (<>){
i = i*n;
}
What should be written in place of <> so that the loop ends when i is at least 34? You may assume n is an int variable that has been declared and given a value prior to this code (the value of n does not affect the answer to this question).
Enter answer here
Q1. Of the following, which is the correct syntax to declare an array of 24 boolean elements named arr?
Q2. Given the declaration of the 24 element boolean array arr above, what is the index of the last element of the array?
Q3. If you wanted to initialize the boolean array arr so that all elements contain the value true, you could use the following: arr.fill(true);
Q4. Arrays of class type require a two-phase initialization. One phase to create the array and another phase to create the objects in the array.
Q5. Given an integer array named arr, the number of elements in the array can be determined by the following method call: arr.length()
Q6. Which of the following statements is true (pick only one):
Q7. What is the value of the variable s after the following section of code executes?
123456
int s = 0;
int [] a = {12, 23, 34, 45, 56};
for (int i=1; i<a.length; i++)=”” {<br=””>
s += a[i]; }</a.length;>
Q8. What type of collection would we use if we wanted no duplicates?
Q9. Examine the following code:
12345678
ArrayList list = new ArrayList() ;
list.add(“alpha”);
list.add(“bravo”);
list.add(“charlie”);
list.add(“delta”);
list.add(“echo”);
Which of the following will replace the element “charlie” with “foxtrot”?
Q10. Examine the following code:
12345678
ArrayList list = new ArrayList() ;
list.add(“alpha”);
list.add(“bravo”);
list.add(“charlie”);
list.add(“delta”);
list.add(“echo”);
Which of the following will change the list so that it looks like:
1234
alpha
bravo
charlie
delta
Q11. Examine the following code:
123456789101112
ArrayList list = new ArrayList() ;
list.add(“alpha”);
list.add(“bravo”);
list.add(“charlie”);
list.add(“delta”);
list.add(“echo”);
for ( name : ) {
out.println( __ );
Fill in the blanks so that all the elements in the ArrayList are printed.
Q12. A HashMap can map keys of any type to values of any type.
Q13. Which of the following is not a feature/advantage of a HashMap?
Q1. An object is
Q2. A typicial object oriented program
Q3. An example of abstraction would be
Q4. An example of an instance of the City class would be
Q5. A class file is (select all that apply)
Q6. A String object is (select all that apply)
Q7. Select all of the Java statements that would compile (would not cause an error).
Q8. Given the following objects
Q1. Making instance variables of a class private
Q2. A class method such as addMonthlyBonus(double x) that receives an input parameter and uses it to change the instance variable of an object is called a
Q3. Select all of the following method definitions below that employ the correct syntax to define a constructor for the class Vehicle. A partial list of the class instance variables includes:
123
int year;
double odometer;
…
Q4. When a constructor is written for the class (select all that apply)
Q5. When calling one constructor from another constructor
Q6. Consider these two methods which are part of the Student class. Assume that age is a private instance variable of the class.
1234567
public void setAge(int years, int months){
age = years * 12 + months; }
public void setAge(int months){
age = months; }
These methods are an example of (select all that apply)
Q1. Which code segment illustrates a correct way to declare an array of 10 objects. Assume the class Beverage has been created.
Q2. Consider the following incorrect code segment. Assume the Pet class has been defined and contains the method setName(String).
12
Pet customer[] = new Pet[5];
customer[3].setName(“Spot”);
We learned that this code is incorrect because…select the best explanation
Q3. Select all of the code segments that properly create an array of 3 objects and instantiate them. Assume the class Lesson has been created.
Q4. When an object is passed as a parameter, its state is changed within the method that it was passed to because…
Q5. Consider the code
12
Pet sparky = new Pet();
Pet fido = sparky;
Line 2 of this code…
Q6. Select all of the scenarios where using a static class constant would be appropriate.
Q1. Consider a class Student whose state includes name and age, Joanne who is a Student, and PartTime whose state includes all of the fields of Student and also maximumHours.
Student is a _________
Joanne is a _____________
PartTime is a ________
Student object
subclass
client
subclass
Student object
super class
Student object
inherited class
Q2. When creating a subclass
Q3. Why do we aim to minimize the amount of code we have to write by not repeating code segments within a Java project? Check all that apply
Q4. To make a call from a subclass to a public, overloaded method whose implementation details are in its super class,
Q5. To make a call from a subclass to a public, overridden method whose implementation details are in its super class
Q1. Lines 54-58 show an example of
Q2. Line _ is the first line of a overridden method in the subclass.
Enter answer here
Q3. Line _ is the first line of a mutator method that is inherited by the subclass.
Enter answer here
Q4. LIne _ is the first line of a method in the super class that is not inherited by the subclass.
Enter answer here
Q5. Select all of the lines of code that could be written in the subclass. (i.e. would not cause a compile error or a runtime error)
Q6. Select all of the lines of code that could be written in a client file that was in the same project as the Month and SchoolMonth classes.
I hope this Java for Android Coursera Quiz Answers would be useful for you to learn something new from the Course. If it helped you, don’t forget to bookmark our site for more Quiz Answers.
This course is intended for audiences of all experiences who are interested in learning about new skills in a business context; there are no prerequisite courses.
Keep Learning!
Former Vice President Phelekezela Mphoko has died aged 84, presidency spokesman George Charamba has confirmed.…
The Zimbabwe School Examinations Council (ZIMSEC) opened its online portal for Grade 7 results…
2024 ZIMSEC Grade 7 Results Now Out The Zimbabwe School Examinations Council (ZIMSEC) has officially…
We’re bringing free WiFi to different parts of Zimbabwe to help you access eduzim.co.zw for…
Sadza is a simple, hearty dish that forms the backbone of many Zimbabwean meals. It's…
Caesar Salad A classic Caesar salad is a simple yet flavorful dish with crisp romaine…