Find Content

Java for Android Coursera Quiz Answers

Get All Weeks Java for Android Coursera Quiz Answers

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

Week 1: Java for Android Coursera Quiz Answers

Quiz 1: Module 1 Quiz

Q1. Which of the following are key concepts found in all object-oriented programming languages, according to the lessons in this module?

  • Concurrency
  • Abstraction
  • Lambda expressions
  • Polymorphism
  • Transactional memory
  • Inheritance

Q2. Which of the following are examples of data abstraction features supported by Java, according to the lessons in this module?

  • if statements
  • Classes
  • Interfaces
  • for loops


Q3. Which of the following is the best definition of an “abstract data type” (ADT), according to the lessons in this module?

  • An ADT separates the control flow paths of normal app execution from the control flow paths of anomalous app execution.
  • An ADT selectively alters the flow of control through an app so it performs different computations based on programmer-specified conditions.
  • An ADT defines a set of data values and a set of operations on these values.
  • An ADT defines an anonymous method that can be passed as an argument or returned as the value of method calls.

Q4. Which of the following are accurate descriptions of differences between Java classes and interfaces, according to the lessons in this module?

  • A Java interface cannot be instantiated directly, whereas a class can.
  • A Java class is a data abstraction mechanism, whereas a Java interface is a control abstraction mechanism
  • A Java interface provides a subset of the features provided by a Java class.
  • A Java class can be part of a package, where as a Java interface can’t.

Q5. Which of the following are benefits of Java generics, according to the lessons in this module?

  • It separates the control flow paths of normal app execution from the control flow paths of anomalous app execution.
  • They help eliminate unnecessary duplication of code.
  • They automatically reclaim and recycle objects that are not currently in use by an app.
  • They ensure compile-type safety when operating on different types.

Q6. Which of the following are benefits of inheritance in Java, according to the lessons in this module?

  • It hides a class’s internal representation to ensure apps using the class can only access its public operations.
  • It determines the order in which individual statements or method calls are evaluated or run.
  • It enhances reuse by allowing classes to reuse common state and behavior from other class.
  • It provides a namespace for organizing Java code in a logical manner.

Q7. Which of the following describe the purpose of exception handling in Java, according to the lessons in this module?

  • It enables the repetition of a block containing one or more statements within an app.
  • It separates the control flow paths of normal app execution from the control flow paths of anomalous app execution.
  • It simplifies the management of large software projects by avoiding collisions between classes that have the same common name.
  • It makes Java apps more robust and easier to understand and evolve.

Q8. Which of the following describe the purpose of polymorphism in Java, according to the lessons in this module?

  • It separates the control flow paths of normal app execution from the control flow paths of anomalous app execution.
  • It defines an anonymous method that can be passed as an argument or returned as the value of method calls.
  • It enables transparent customization of methods in a subclass that are inherited from a super class.
  • It enables the passing of types as parameters to the definition of classes, interfaces, and methods.

Q9. Which of the following are expectations of learners who take this MOOC, according to the lessons in this module?

  • You are expected to be interested in both the concepts and practice of developing mobile apps
  • You are expected to know how to program Java for Android apps.
  • You are expected have basic computer literacy skills, such as knowing how to send & receive emails and browse the web.
  • You are expected you to have a Computer Science degree.

Q10. Which of the following are recommended strategies for learning the material covered in this MOOC, according to the lessons in this module?

  • Participate in the online discussion forums.
  • Follow the links to articles, tutorials, source code, and documentation provided in the lesson slides.
  • Attend Coursera meet up groups near you.
  • Watch the lessons carefully before taking the quizzes and doing the programming assignments.

Quiz 2: Module 2 Quiz

Q1. What version of the Android API are we going to use in this class?

  • Android API version 28
  • Android API version 22
  • Android API version 29
  • Android API version 30

Q2. Which Android Studio wizard button will you use to -Open- an existing project?

  • Start a new Android Studio project
  • Open an existing Android Studio project
  • Import project (Gradle, Eclipse ADT, etc.)
  • Configure

Q3. There is a folder in Android Studio projects called ‘res’. What does ‘res’ mean?

  • responsible
  • reveal
  • resources
  • regular expression system

Q4. By convention which of these names is in proper formatting for a Java class?

  • mathLibrary
  • Mathlibrary
  • MathLibrary
  • mathlibrary

Q5. Bugs(defects) in software can be categorized into two main groups. Which of these match those categories?

  • Syntax and Grammar
  • Logical and Highlighting
  • Highlighting and Grammar
  • Syntax and Logical

Q6. In Android Studio what does a word having a red squiggly line under it likely mean?

  • That word likely has a desire to be a blue line, but it didn’t study enough to get into ‘Squiggly Blue Line School’
  • That word likely has too much teen spirit.
  • That word likely has hurt feelings.
  • That word likely has a syntax error

Q7. Which of the following is not a step in running our code in the supplied Android app?

  • Select “app” from the configuration drop-down menu
  • Select an AVD with API 29 that will run on our computer
  • Right-click on Logic.java and select Run
  • Press the Run button on the tool bar

Q8. To submit your solution to the auto-grader so that you can receive a grade…

  • You upload the file Logic.java to the Coursera server.
  • You use the submitForGrading gradle task to create submission.zip that you will upload to the Coursera server.
  • You will run the supplied unit tests on your computer to grade your submission.
  • You use the graderPreview gradle task to grade your submission.

Quiz 3: Module 3 Quiz

Q1. What is the value of this expression:

54 % 10 + 6 * 3 % 4

  • None of the other options
  • 22
  • 9
  • 6
  • 9.9

Q2. Which operator in the following expression will be evaluated first?

2 / (1.0 + 2 * 3) – 2

  • The multiplication * operator
  • The division / operator
  • The addition + operator
  • The subtraction – operator

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.

  • FALSE
  • TRUE

Q4. Given a String object called str, the statement str.toUpperCase(); will change the object to have all uppercase letters:

  • FALSE
  • TRUE

Q5. The following string is a legal Java identifier that could be used as a variable name or a method name: _am_I_okay

  • FALSE
  • TRUE

Q6. The programmer can manually change data values from one type to another type by an operation called a type-_

  • cast
  • alteration
  • coercion
  • convert

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 + ” “);

  • 99 22 99
  • 22 99 22
  • 22 22 22
  • 22 99 99
  • 22 22 99

Q8. Given variable x of type double, which of the following result in a different value being assigned to x?

  • They are all equivalent; i.e. all assign the same value to x
  • x = 32.0/5.0
  • x = 32/5.0
  • x = (double)(32/5)
  • x = 32.0/5

Q9. The following code always prints the value 9:

12

int x = 8;

out.println(x++);

  • FALSE
  • TRUE

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.

  • TRUE
  • FALSE

Q11. What reserved word is used to indicate that a method does not return a value?

  • public
  • void
  • return
  • static

Q12. A bit can have __ different values.

  • 8
  • 2
  • 256
  • 100

Week 2: Java for Android Coursera Quiz Answers

Quiz 1: Module 4 practice quiz on IF statements

Q1. What is the truth value of the following expression?

(-8 >= 9) || (14 > 2)

  • True
  • False

Q2. What is the truth value of the following expression?

(5 > 0) && (7 > 0)

  • True
  • False

Q3. What is the truth value of the following expression?

(8 != 7) && (4 > 4)

  • True
  • False

Q4. What is the truth value of the following expression?

!(8 >= 2*3) || (7 >= 11)

  • True
  • False

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);

  • 37
  • 27
  • 10
  • 20

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%”);

}

  • 1 You can purchase a wristband for $10
  • 123 You can purchase a wristband for $10

    Your cost is discounted by 15%
  • 1234 Your cost is discounted by 10%

    You can purchase a wristband for $10

    Your cost is discounted by 15%

    You may enter for free
  • 123 You can purchase a wristband for $10

    Your cost is discounted by 15%

    You may enter for free

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
  • -7

3

  • -17
  • -7

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

  • 16
  • 23
  • 7
  • -4

Quiz 2: Module 4 quiz on FOR loops

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?

  • 0
  • 4
  • 5
  • 6
  • infinitely many

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?

  • 0
  • 4
  • 5
  • 6
  • infinitely many

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?

  • 0
  • 4
  • 5
  • 6
  • infinitely many

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?

  • 0
  • 5
  • 10
  • 15
  • infinitely many

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?

  • 0
  • 5
  • 10
  • 15
  • infinitely many

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

Quiz 3: Module 4 practice quiz on indefinite loops

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?

  • 14 11 8 5 2
  • The loop would not execute at all.
  • 14 11 8 5
  • 17 14 11 8 5

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?

  • 23 18
  • 23
  • The loop would never execute.
  • The loop would run continuously, repeatedly printing out the number 23.

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?

  • 123 for (int i = 10; i>0; i=i-2){

    out.print(i + ” “);}
  • 123 for (int i = 0; i>0; i = i+2){

    out.print(i + ” “);}
  • 123 for (int i = 10; i<0; i = i-2){

    out.print(i + ” “);}
  • 12 for (int i = 10; i<0; i++){

    out.print(i + ” “);

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?

  • for loop, because each player will roll a predetermined number of times.
  • while loop, because every player must roll at least once.
  • do-while loop, because every player must roll at least once.
  • do-while loop, because a player may choose not to roll at all.

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

Quiz 4: Module 5 Quiz

Q1. Of the following, which is the correct syntax to declare an array of 24 boolean elements named arr?

  • boolean arr[24];
  • boolean[] arr = new boolean[24];
  • boolean arr[] = new boolean;
  • boolean arr = new boolean[24];
  • boolean[24] arr = new boolean[24];

Q2. Given the declaration of the 24 element boolean array arr above, what is the index of the last element of the array?

  • 23
  • 22
  • 25
  • 24

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);

  • TRUE
  • FALSE

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.

  • FALSE
  • TRUE

Q5. Given an integer array named arr, the number of elements in the array can be determined by the following method call: arr.length()

  • TRUE
  • FALSE

Q6. Which of the following statements is true (pick only one):

  • An array can be sized dynamically, but it cannot be resized without allocating a new array.
  • An array can be sized dynamically, and it can be resized without allocating a new array.
  • An array cannot be sized dynamically when the program is running.

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;>

  • 170
  • 158
  • 114
  • 0

Q8. What type of collection would we use if we wanted no duplicates?

  • Map
  • Set
  • List
  • Queue

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”?

  • list[2] = “foxtrot”;
  • list.set(list.indexOf(“charlie”),”foxtrot”);
  • list.add(“foxtrot”, list.indexOf(“charlie”));
  • list.set(“charlie”,”foxtrot”);
  • list.set(“foxtrot”,”charlie”);

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

  • list.remove(list.size()-1);
  • list.remove(list.size());
  • list.clear(“echo”);
  • list.empty(“echo”);
  • list.remove(5);

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.

  • 1 String iterator() next()
  • 1 iterator() hasNext() next()
  • 1 String list name
  • 1 String list next()
  • 1 int String name

Q12. A HashMap can map keys of any type to values of any type.

  • FALSE
  • TRUE

Q13. Which of the following is not a feature/advantage of a HashMap?

  • HashMaps can use any object type as a key.
  • HashMaps have fast insert.
  • HashMaps have fast lookup.
  • HashMaps keep their keys in sorted order.

Week 3: Java for Android Coursera Quiz Answers

Quiz 1: Module 6 quiz on Object Oriented Programing concepts

Q1. An object is

  • The grouping together of data and behavior to create a single entity
  • The blue print for creating classes
  • A way to hide implementation details from the user
  • A sequence of characters

Q2. A typicial object oriented program

  • must consist of at least four classes.
  • uses objects to perform most of its useful behavior.
  • uses objects to model the behavior of the ints, chars and boolean variables used in the program.
  • uses methods and primitive data types to perform most of its useful behavior.

Q3. An example of abstraction would be

  • only selling digital cameras to experienced users.
  • supplying a Quick Start guide with a digital camera.
  • supplying the technical drawings with a digital camera.
  • supplying batteries with a digital camera.

Q4. An example of an instance of the City class would be

  • the variables Name, Latitude, Longitude, Country and Population.
  • the methods to update the city’s population and to calculate the distance to other cities.
  • the city of Philadelphia.
  • the plans for a city.

Q5. A class file is (select all that apply)

  • a file containing a single program or module.
  • a template or blueprint for an object.
  • a collection of objects.
  • a collection of keywords.

Q6. A String object is (select all that apply)

  • similar to primitive data types in some respects.
  • a primitive data type.
  • a reference to a memory location where data is stored.
  • a sequence of characters.

Q7. Select all of the Java statements that would compile (would not cause an error).

  • 123

    String str1 = “hi”;

    String str2 = “HI”;

    out.println(str1 == str2);
  • 123

    String str1 = “hi”;

    String str2 = “HI”;

    out.println(str1.equals(str2));
  • 12

    String str1 = “Good programming”;

    out.println(str1.concat(18.9));
  • 1

    out.println(“Hello” + ” programmers!”);
  • 1

    out.println(“Hello kids” – “kids”);

Q8. Given the following objects

  • 12

    String str1 = “held”;

    String str2;

    How could you create the string herald?
  • 12

    str1 = str1.substring(0,2) + “ra”;

    str1 = str1 + str1.substring(2,4);
  • 1

    str2 = str1 + “ra”;
  • 123

    str1.substring(0,2);

    str2 + “ra”;

    str2.concat(str1.substring(2,4));
  • 123

    str2 = str1.substring(0,2);

    str2 = str2 + “ra”;

    str2 = str2.concat(str1.substring(2,4));

Quiz 2: Module 6 quiz on methods and classes

Q1. Making instance variables of a class private

  • is an application of abstraction and protects the behaviors of an object from being modified by users.
  • is an application of security and protects against hackers modifying and corrupting our code.
  • is an application of abstraction and protects against object users gaining direct access to object state.
  • is a requirement of Java. A class won’t compile unless all fields are declared 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

  • mutator method
  • constructor
  • accessor method
  • default constructor

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;

  • 12

    public Vehicle(){ }
  • 1234

    public void Vehicle(double mileage){

    odometer = mileage; }
  • 123

    public makeVehicle(int year){

    this.year = year; }
  • 1234

    public Vehicle(double mileage, int year){

    this(mileage);

    this.year = year; }
  • 1234

    public Vehicle(double odometer, int year){

    odometer = odometer;

    year = year; }


Q4. When a constructor is written for the class (select all that apply)

  • the default constructor can not be recreated.
  • the default constructor is no longer available.
  • no other constructors can be written.
  • the default constructor must be recreated if it is to be used by client programs.

Q5. When calling one constructor from another constructor

  • the keyword this is used and must be the last line of the constructor code.
  • two objects are created, one being created by each constructor.
  • the class name is used to refer to the called constructor.
  • the keyword this is used and must be the first line of the constructor code.

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)

  • accessors.
  • overloading.
  • mutators.
  • overriding.

Quiz 3: Module 6 quiz on arrays and parameters

Q1. Which code segment illustrates a correct way to declare an array of 10 objects. Assume the class Beverage has been created.

  • 1 Beverage[] guestList = new Beverage[10];
  • 1 Beverage guestlist = array[10];
  • 1 Beverage[10] guestList;
  • 1 new guestlist[10];

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

  • The proper syntax for a set method called on an object is 1 setName(customer[3], “Spot”);
  • all five of the names must be set at one time.
  • although the array of Pet references has been created, none of them point to Pet objects yet. Each object must be instantiated individually.
  • objects stored in an array can not be accessed individually. They can only be accessed as a group.

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.

  • 1234

    Lesson [] week1 = new Lesson[3];

    for (int i = 0; i<week1.length; i++){<br=””>
    week1[i] = new Lesson(); }</week1.length;>
  • 1 Lesson [] week1 = {new Lesson(), new Lesson(), new Lesson()};
  • 1 Lesson [] week1 = new Lesson[0], new Lesson[1], new Lesson [2];
  • 1 Lesson[3] = week1[0], week1[1], week1[2];

Q4. When an object is passed as a parameter, its state is changed within the method that it was passed to because…

  • the value of the object (its state) was passed.
  • the object was updated when the return statement was executed.
  • the reference to the object was passed.
  • a copy of the object was passed.

Q5. Consider the code

12

Pet sparky = new Pet();

Pet fido = sparky;

Line 2 of this code…

  • compares the object fido do the object sparky and returns true or false.
  • creates a new object named sparky with the same state data found in fido.
  • sets the object fido to reference or “point to” the object sparky.
  • creates a new object named fido with the same state data found in sparky.

Q6. Select all of the scenarios where using a static class constant would be appropriate.

  • To declare a constant that is used in different methods of the class and whose value never changes.
  • To declare a constant that is somehow associated with the class and may be accessed by client programs.
  • To declare a variable that is used in different methods of the class. This helps to avoid having to pass and return it as a parameter.
  • To share the state of that variable across many different objects of the class, like a count variable to keep track of how many objects have been created.

Quiz 4: Module 7 quiz on inheritance

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 ________

  • super class

Student object

subclass

  • super class

client

subclass

  • sub class

Student object

super class

  • super class

Student object

inherited class

Q2. When creating a subclass

  • only write the instance variables and methods that are added to the subclass.
  • only write the methods that are public.
  • only write the instance variables and methods that are inherited by the subclass.
  • write both the inherited and the additional state and behavior of the 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

  • It improves readability, code is easier to trace when implementation details are found in only on location.
  • It makes a program run faster.
  • It facilitates code reuse. An object that contains all of its state and behavior in a single file is “portable” and can be included in many different Java projects.
  • It makes debugging easier. Implementation details that only appear once in a project can be corrected or improved by editing in only one place.
  • It makes projects unique. An object that contains all of its state and behavior in a single file is not easily reused.

Q4. To make a call from a subclass to a public, overloaded method whose implementation details are in its super class,

  • you must precede the call with the keyword super to indicate that the implementation details are in the super class.
  • simply make the call. The unique return type and/or parameter list will enable the compiler to locate the implementation details.
  • simply make the call. The implementation details found in the subclass will automatically be used.
  • you must precede the call with the keyword sub to indicate that you are writing the method in the subclass.

Q5. To make a call from a subclass to a public, overridden method whose implementation details are in its super class

  • simply make the call. The unique return type and/or parameter list will allow the compiler to locate the implementation details.
  • you must precede the call with the keyword super to indicate which version of the method you are calling.
  • A subclass can not call a method in its super class.
  • you must precede the call with the keyword this to indicate which version of the method you are calling.

Quiz 5: Module 7 quiz on code “dissection”

Q1. Lines 54-58 show an example of

  • a mutator method that makes an explicit call to a constructor in the super class.
  • a constructor that makes an implicit call to a constructor in the super class.
  • a default constructor in a subclass.
  • a constructor that makes an explicit call to a constructor in the super class.

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)

  • 1 convertToString();
  • 1 setMonth(8);
  • 1 super.setMonth(8);
  • 123 String inputString;



    this.name = inputString;
  • 1 int num = super.getDays();
  • 1 super.convertToString();

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.

  • 12 SchoolMonth x = new SchoolMonth(7);

    setMonth(4);
  • 12 SchoolMonth x = new SchoolMonth(7);

    x.setMonth(3);
  • 1 Month[] summer = new Month[3];
  • 1 Month x = new Month();
  • 12 SchoolMonth y = new SchoolMonth(11);

    y.semester = ‘F’;
Conclusion:

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!

Ezoic

Leave a Reply

Your email address will not be published. Required fields are marked *