Answer 9) (B) classB::functioName();
In order to call the base class function we use base class name becuase the derived class has overridden this function. So, in order to avoid ambiguity we use base class name with :: to call base class function.
Answer 11) (B) class
A function template declaration is:
template <class T> T anyFunctio(T arg){
}
Here generic data type keyword is class followed by T that can accept different data types such as int,float and so on.
Answre 12) (D) 84
p= &x. Here p gets the address of x variable. Now then *p = 84. The *p represent the value at address p and here we change it to 84. Thus the value of x changes to 84.
Answer 13) (B) catch(...) { }
This statement will capture every exception
Question 9 4 pts If the derived class class Doverrides a public member function functionName of...
In a function template, a generic data type starts with the key word _____ followed by a parameter name that stands for the data type. template class T function Which of the following blocks is designed to catch any type of exception? catch(){ } catch(...){ } catch(*){ } catch(exception){ } A friend function can only be a regular stand-alone function and can not be a member of another class. True False A function template is an actual function that the...
If the derived class overrides a public member function of the base class, then to specify a call to that public member function of the base class you use the name of the base class, followed by the ____ operator, followed by the function name with the appropriate parameter list. Question 16 options: 1) : 2) . 3) :: 4) $
Add a public member function to the BST class below that returns the size of the tree—the number of the nodes in the tree. For simplicity, the class contains only the key and not a value. You may add any helper functions you find necessary. (Hint: think recursion) template <typename T> struct Node { T key; Node<T>* left; Node<T>* parent; Node<T>* right; }; template <typename T> class BST { private: Node<T>* root; public: BST():...
Question 14 4 pts Which of the following is the general syntax of the function prototype to overload the post-increment operator as a member function? className operator++ 0); friend className operator++(); className operator++ (int): friend className operator ++ (int); Question 15 4 pts Which of the following is a built-in operation on classes? increment assignment decrement relational Question 16 4 pts A friend function can only be a regular stand-alone function and can not be a member of another class....
Create a base class and two derived classes. Also, create and call a member function named communicate() that behaves differently when called by each class. Create a single C++ project (and CPP source file) named animal_communication as follows: Into this source, type the source code for Program 15-16, "Program Output," in Section 15.6, "Polymorphism and Virtual Member Functions," in Ch. 15, "Inheritance, Polymorphism, and Virtual Functions," of Starting Out With C++ From Control Structures Through Objects. Run and debug the...
Write a full class definition for a class named Player , and containing the following members: A data member name of type string . A data member score of type int . A member function called setName that accepts a parameter and assigns it to name . The function returns no value. A member function called setScore that accepts a parameter and assigns it to score . The function returns no value. A member function called getName that accepts no...
TreeNode.java
public class TreeNode {
public int key;
public TreeNode p;
public TreeNode left;
public TreeNode right;
public TreeNode () {
p = left = right = null;
}
public TreeNode (int k) {
key = k;
p = left = right = null;
}
}
BinarySearchTree.java
public class BinarySearchTree {
public TreeNode root;
public BinarySearchTree () {
root...
In Java Which of the following statements declares Salaried as a subclass of payType? Public class Salaried implements PayType Public class Salaried derivedFrom(payType) Public class PayType derives Salaried Public class Salaried extends PayType If a method in a subclass has the same signature as a method in the superclass, the subclass method overrides the superclass method. False True When a subclass overloads a superclass method………. Only the subclass method may be called with a subclass object Only the superclass method...
D Question 18 4 pts A function template is an actual function that the compiler uses to generate one or more functions. True False D Question 19 4 pts Calls to methods use the class identifier instead of the object identifier as the method qualifier. constructor friend static this Question 20 4 pts If inheritance is private, all members of the base class, including private members, become private members of the derived class. True False Question 21 4 pts is...
Question 1 2 pts The preprocessor executes after the compiler. False True Question 2 2 pts What code is human-readable and follows the standards of a programming language? Secret code Source code Key code None of these Machine code Question 3 2 pts What is the symbol that marks the beginning of a one line comment? Question 1 2 pts The preprocessor executes after the compiler. True False Question 5 2 pts A statement that may be used to stop...