Get Mastering Programming with MATLAB Coursera Quiz Answers
Mastering Programming with MATLAB Week 01 Quiz Answers
Quiz : Introduction to Object Oriented Programming
Q1. An object’s type …
- is called “method.”
- is defined using keyword “classdef.”
- is defined by MATLAB.
- is called “classtype.”
Q2. In OOP, the following statements are true about an object except for
- Objects can contain data and functions
- Objects are stored in a variables.
- An object is like a struct data type with fewer features.
- All of the above are correct.
Q3. A class can contain the following except for
- save-access method
- set-access method
- constructor method
Q4. A new sub-class that inherits from a super class (or a base class) cannot
- create new properties and methods.
- call the super class constructor after the object has been used in the class.
- inherit all the properties from the super class.
- modify the set-access methods inherited from the super class.
Q5. If a user made a change in a class definition,
- the change affects the current instances of that class.
- the change does not affect the current instances of its sub-classes.
- the current instances of the class are only affected if the change is in a method.
- nothing will change in the current instances.
Quiz : Handle Classes
Q1. What is the name of the built-in class that supports pointer semantics?
- object class
- link class
- handle class
- access class
Q2. A user can modify a property of an instance of a value class inside a method of the class by
- There is no way to do that in a value class.
- ensuring the output argument of the method is set to be the object.
- deleting the object and recreating it again.
- defining a new property with a new value.
Q3. Handle classes should be used carefully because
- the properties inside the handle class are unknown.
- the methods inside the handle class are unknown.
- a variable can be easily modified from the workspace.
- a user can write methods that change the properties of an object within the class definition that will be visible outside of the method’s scope.
Q4. How can a class prevent direct access to its properties?
- It cannot. All properties must be public so methods can use them.
- By setting methods to restricted access.
- By making them private.
- By setting the properties to empty matrices.
Q5. Which of the following is incorrect?
- Private properties can be viewed by creating a display function or defining a get-access method.
- A class can consist of public, protected and private properties
- A class can specify which other classes can access its properties.
- If a class declares its properties private, the properties of its subclasses become private as well.
Quiz : More on OOP
Q1. Operator overloading means
- redefining the behavior of built-in MATLAB operators for instances of the given class.
- providing multiple implementations of certain operators for a given class.
- testing operators with large operands to make sure they can handle them.
- None of the above.
Q2. A class having at least one abstract method means that
- it cannot be instantiated.
- its subclasses will need to implement all of its abstract methods otherwise they would remain abstract classes themselves.
- it is an abstract class.
- All of the above
Q3. Which of the following statements is false?
- Argument validation can be used to check the type and size of the actual input arguments used to call the function.
- Argument validation works with ordinary functions, methods of classes and even nested functions.
- Argument validation can be used to provide default values to input arguments of functions, hence, such functions can be called with the given arguments omitted.
- Argument validation can save the programmer work and make the code more readable by not having to write extra code that checks the assumptions about the input arguments of functions.
Q4. Which of the following is not a function implementing a relational operator?
Q5. Which of the following statements is true?
- A subclass inherits all properties and methods of its superclass.
- There is no way for a class to access the private properties of another class.
- When a class A is put on the access list of class B, all subclasses of class A have the same access to class B as class A itself.
- None of the above
Quiz : Tying It All Together
Q1. How do we enforce that a property must be a char-type inside a class?
- Set property qualifiers for the given property inside the class.
- Creating a property get method and set the property to char-type.
- The class cannot validate the properties inside the class definition.
- Create a function that checks all the properties.
Q2. Which is NOT true about Object Oriented Programming?
- Users do not have to worry about how the class is implemented; they can simply use objects of the class via its public methods and properties.
- Hiding the object details with the techniques we learned still cannot prevent users from making direct changes to the object from outside of the class definition.
- You can make properties that are not accessible from outside of the class definition but still are accessible to subclasses.
- You can make properties that are not accessible from outside of the class definition but are accessible to certain other classes.
Q3. Benefits of inheritance in the Object-Oriented Programming include
- Code can be reused from the super class.
- A subclass can be considered a specialized version of the super class.
- A dynamic relationship between classes can be created by inheritance where changes in the super class automatically propagate to its subclasses.
- All of the above.
Q4. Polymorphism in OOP helps developers write class definitions by
- The ability to override the public and protected methods inherited from the super class.
- The different access settings for methods and properties.
- The ability to redefine operator implementations.
- All of the above.
Mastering Programming with MATLAB Week 02 Quiz Answers
Quiz : Graphical User Interfaces
Q1. How do we launch the App Designer in MATLAB?
- By typing appdesigner in the MATLAB command window.
- By selecting the “App” item under the “New” menu in the “Home” tab.
- By clicking “Design App’” in the “Apps” tab
- All of the above
Q2. What is the file extension for the MATLAB application created in the MATLAB?
Q3. Which of the following is true?
- We can add, modify or remove any code for the app in the Code View tab.
- The app name is the same as the name of the class defined in the app code.
- The designed GUI is a subclass of a MATLAB class called matlab.GUI.app.
- The components in the app are initialized in the method called createFigure.
Q4. Callback functions of a widget can be used to
- leave a phone number where the user can call the creator of the app to ask any questions.
- react to events generated by the user interacting with the widget.
- to extend the functionality of the application once it has been deployed.
- set up the initialization of the application.
Q5. If we want to add a new property to the application,
- we can define the new property inside the existing automatically generated property declaration.
- we can create new properties with public access only.
- we can define the new property separately from the automatically generated ones with public, protected or private access.
- no new property can be added manually.