Question 1
2 pts
(TCO 7) Instances of a(n) _____ cannot be created.
abstract class
public function
pure virtual function
public class
Question 2
2 pts
(TCO 7) What is an abstract class?
A generalized class used only to create related derived classes
A class without any superclasses
Any subclass with more than one superclass
A class from which we create many instances
Question 3
2 pts
(TCO 7) Which of the following statements is false?
Pure virtual functions are inherited.
If a derived class extends an abstract base class, the derived class must implement the pure virtual functions declared in the abstract base class.
Any method in an abstract class is considered a pure virtual function.
A pure virtual function is a function without function implementation and can be found in an abstract class.
Question 4
2 pts
(TCO 7) Which of the following classes is most likely an abstract class?
EvoCellPhone
Rose
Building
FijiApple
Question 5
2 pts
(TCO 7) In terms of object-oriented programming, a contract is a mechanism that forces a programmer to adhere to a predefined application programming interface or _____.
class declaration
object instantiation method
framework
method signature
None of the above
Question 6
2 pts
(TCO 7) Which is the prototype for a pure virtual function in class TVGame called StartGame which has no inputs and returns a bool?
bool virtual StartGame()
bool virtual TVGame::StartGame(string) = 0;
virtual bool TVGame::StartGame() {}
virtual bool StartGame() = 0;
Question 7
2 pts
(TCO 7) C++ allows for the implementation of multiple inheritance, whereas .Net and Java do not. However, in languages such as .Net and Java, _____ can be used to simulate multiple inheritance.
base classes
interfaces
abstract methods
implementations
Question 8
2 pts
(TCO 7) Which of the following classes represent an abstract class?
class Plant {
virtual void grow (){}
}
class Plant {
virtual void grow ();
}
class Plant {
virtual void grow (){}
}
class Plant {
virtual void grow()=0;
}
Question 9
2 pts
(TCO 7) Which of the following declares an abstract method in an abstract C++ class?
public: virtual void print() {}
public: virtual void print()=0;
public: void print() {}
public: void print();
Question 10
2 pts
(TCO 7) Assume the function area is a pure virtual function. Which prototype would a programmer use in the class declaration for the class TwoDimensionalShape?
virtual void area() = 0;
void virtual area() = 0;
virtual void area()
void TwoDimensionalShape::area() = 0;
Expert Answer
Q1-Abstract class – instance of an abstract class cannot be created but the class extending it can have instance.
Q2-A class with any superclasses
Q3-Aby method in an abstract class is considered a pure virtual function (because a pure virtual function can is written as void fun()=0 so any method cannot be considered as a pure virtual function.)
Q4- Building because(building can be a base class whose types can be there and each type has its own features.)
Q6-virtual bool StartGame() = 0;
Q7-Interfaces are used in java and .net for the purpose of multiple inheritance as extending multiple classes is not allowed in java and .net where as multiple interfaces can be implemented.
Q8-class Plant {
virtual void grow()=0;
} because classes with pure virtual functions are automatically considered as abstract.
Q9-public: virtual void print()=0;
Q10-virtual void area() = 0;