Quiz - POO
Quiz - POO
- [ ] any method
- [ ] method overloading
- [x] method overriding
- [ ] compiling
#### Q2. For which case would the use of a static attribute be
appropriate?
#### Q3.1 Why would you create an abstract class, if it can have no
real instances?
#### Q3.2 Why would you create an abstract class, if it can have no
real instances?
- [ ] It implies encapsulation.
- [ ] A superclass object has an IS-A relationship with its subclass.
- [ ] It implies a virtual method.
- [x] A subclass object has an IS-A relationship with its superclass
or interface
#### Q8. You want a method with behavior similar to a virtual method--
it is meant to be overridden --expect that it does not have a method
body. It just has a method signature. What kind of method should you
use?
#### Q9. Which code creates a new object from the Employee class?
- [ ] default
- [ ] copy
- [ ] parameterized
- [x] Constructors do not have a return type
- [x] when an object is created from a class using the new keyword
- [ ] when an class is defined using the class keyword
- [ ] every time an object is referenced
- [ ] when an object is created from a class using the create keyword
- [x] The object can be accessed, declared, and used locally in that
function.
- [ ] The object must be declared inside any other function.
- [ ] The object is temporarily accessible outside the function.
- [ ] The object can call all the other class members anywhere in the
program.
#### Q13. Which two blocks are used to handle and check errors?
- [ ] do and check
- [ ] catching and trying
- [x] try and catch
- [ ] do and while
- [ ] multilevel
- [ ] hierarchical and multiple
- [x] hierarchical
- [ ] multiple
#### Q20. How are user stories different from use cases?
- [x] multiple
- [ ] any type of inheritance
- [ ] multilevel
- [x] hierarchical
#### Q22. A language that does not support polymorphism but supports
classes is considered what?
#### Q23. If two classes combine some private data members and
provides public member functions to access and manipulate those data
members. Where is abstraction used?
#### Q24. What are the five Creational Design patterns by the Gang of
Four ?
- [ ] camera
- [ ] display
- [ ] motherboard
- [x] mobile phone
- [ ] multilevel inheritance
- [x] double inheritance
- [ ] single inheritance
- [ ] hierarchical inheritance
#### Q33. What does the code shown below demonstrate, and why?
```cpp
static void Multiply(int num1, int num2) {};
static void Multiply(double num1, double num2, double num3) {};
static void Multiply(float num1, float num2) {};
```
[reference link](https://en.wikipedia.org/wiki/Class-responsibility-
collaboration_card)
- [x] a name
- [ ] a state
- [ ] a color
- [ ] an object
- [ ] inline function
- [ ] undefined function
- [x] virtual function
- [ ] class member function
#### Q42. Which words in the following list are candidates for
objects: trumpet, clean, enrage, leaf, tree, collapse, active, and
lively?
#### Q45. What type of inheritance may lead to the diamond problem?
- [ ] single level
- [ ] multilevel
- [ ] hierarchical
- [x] multiple
#### Q52. The open/closed principle states that classes should be open
for \_ but closed for \_.
- [ ] refactoring; duplication
- [ ] modification; duplication
- [x] extension; modification
- [ ] reuse; encapsulation
- [x] The catch block that will be executed is the one that best
matches the type of exception thrown.
- [ ] Multiple catch blocks can never be associated with a single try
block.
- [ ] Multiple catch blocks are mandatory for each try block.
- [ ] Multiple catch blocks will all be executed in the case of an
exception.
#### Q56. There are five classes. Class E is derived from class D, D
from C, C from B, and B from A. Which class constructor(s) will be
called first if the object of E or D is created?
- [x] A
- [ ] B
- [ ] C
- [ ] C and B
#### Q57. You have modules that are dependent on each other. If you
change one module, you have to make changes in the dependent modules.
What term is used to describe this problem, and what is a potential
solution?
- [ ] A class of resources
- [ ] A group of methods
- [x] A collection of objects
- [ ] A list of children
- [x] car:toyota
- [ ] ducks:pond
- [ ] toes:feet
- [ ] rock:stone
#### Q64. Which statements best describe the Gang of Four design
patterns called Memento and Observer?
#### Q65. What does the value (0.5,0.5,0.5) indicate in the class
diagram specification position: Coordinate = (0.5,0.5,0.5)?
#### Q66. What is the most accurate example of the Liskov substitution
principle?
- [ ]
```
public class Car{
}
public class FlyingCars extends Car{
public void fly(){}
}
public class Tesla FlyingCar{}
public class Honda Car{}
```
- [ ]
```
public class Car{
public void fly(){}
}
public class Tesla extends Car{}
public class Honda extends Car{}
```
- [ ]
```
public class Car{
public void fly(){}
}
public class Tesla Car{}
public class Honda Car{}
```
- [x]
```
public class Car{
}
public class FlyingCars extends Car{
public void fly(){}
}
public class Tesla extends FlyingCar{}
public class Honda extends Car{}
```
- [ ] An argument can have many values while a parameter can have only
one value.
- [ ] An argument is the variable used for input values in a method. A
parameter is the specific input value passed to the method.
- [x] A parameter is a variable in the declaration of a function. An
argument is the value of this variable that gets passed to the
function.
- [ ] Parameters and arguments are the same