Question

Question 1 2 pts The preprocessor executes after the compiler. False True Question 2 2 pts...

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 the current loop and continue with the statement following the loop:

Next

Return

Stop

Continue

Terminate

Break

Question 6 2 pts

What is the output of the following loop?

int x = 0;
while (x++ < 5)
{
cout << x << " ";
}

Question 6 2 pts

What is the output of the following loop?

int x = 0;
while (x++ < 5)
{
cout << x << " ";
}

True

False

Question 8 2 pts

This type of variable is defined inside a function and is not accessible outside the function.

Global

Static

Pointer

Local

None of these

Preprocessor directive

Question 9 2 pts

A while loop can be re-written as a: ( please select all that apply)

Do-while loop

Recursive function

For loop

Question 10 2 pts

An instance of a class is an object.

True

False

Question 11 2 pts

A class is a blueprint of an ___________.               

Question 12 2 pts

Inheritance means ____________________________

hiding the internals of a class

passing arguments to a function

assigning an object of a subclass to a variable declared as super class

a class is derived from another class

creating an instance of a class

Question 13 2 pts

Information Hiding means ________________

a class is derived from another class

passing arguments to a function

hiding the internals of a class

creating an instance of a class

assigning an object of a subclass to a variable declared as super class

Question 14 2 pts

The constructor function's return type is

any typed defined by the programmer

the class

void

No return type

Question 15 2 pts

A constructor is a special function that

instantiates a class

can only be called from within a class

must always be explicitly defined

creates a class

Question 16 2 pts

The _ _ is more general than the _ _ .

Question 17 2 pts

If you use the keyword virtual in a function declaration, the function may be overridden in derived classes.

True

False

Question 18 2 pts

Any function declared as public may be overridden in subclasses.

True

False

Question 19 2 pts

Mark everything that is inherited when a class derives from another class.

public member functions

private member variables

public member variables

static member functions

constructor(s)

static member variables

private member functions

Question 20 2 pts

Which of the following is correct syntax for defining a new class AppleJuice based on the supper class SoftDrink?

class AppleJuice : public SoftDrink

class SoftDrink : public AppleJuice

Question 21 2 pts

What is the output of the following program?

class A{

       public:

       virtual void func() { cout<< "A"; }

};

class B: public A{

       public:

       void func() { cout << "B"; }

};

int main (){

       A * val = new B;

       val->func();

       return 0;

}

Question 22 2 pts

If a base class has public member functions that are not listed by a derived class, then these functions

do not exist in the derived class

are inherited unchanged in the derived class

are always private to the derived class

are not available to the derived class

Question 23 2 pts

Polymorphism refers to

overloading functions

overriding base class functions

None of these

the ability to assign objects of subclass types to object pointer variables of superclass types

Question 24 2 pts

Assume a base class has a non-virtual member function named run(). If an object pointer ptr declared as the base class is pointing to an object of a derived class, then the code ptr->run( ); calls

the base class print function

the derived print function

both the derived and base print functions

it causes a run-time error

Question 25 2 pts

Operators can be overloaded in C++

True

False

Question 26 2 pts

A default constructor cannot have more than _____ parameters.

Question 27 2 pts

What is the output of the following program?

class A{

       public:

       void func() { cout<< "A"; }

};

class B: public A{

       public:

       void func() { cout << "B"; }

};

int main (){

       A * val = new B;

       val->func();

       return 0;

}

Question 28 2 pts

In which case would you consider using a dynamic array?

If the array is small, and the size is known before the program runs.

If the program needs to get the size of the array from the user

If the program needs to get the size of the array from the user

You should always use a dynamic array

Question 29 2 pts

If p1 and p2 are both pointers that point to integers in memory, the condition p1==p2 will be true if the values that are in those memory locations are the same.

True

False

Question 30 2 pts

Please complete the following code to make sure that a user input is a positive number larger than 10.

int userInput;

{

cout << "Please input a number larger than 10: ";

cin >> userInput;

} ( );

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. The preprocessor executes after the compiler: False

2. What code is human-readable and follows the standards of a programming language? Source code

3. What is the symbol that marks the beginning of a one line comment? The symbol is: //

4. A statement that may be used to stop the current loop and continue with the statement following the loop: Break

5. What is the output of the following loop?

int x = 0;
while (x++ < 5)
{
cout << x << " ";
}

Answer: 1 2 3 4 5 (Note the extra space after 5)

8. This type of variable is defined inside a function and is not accessible outside the function: Local

9. A while loop can be re-written as a: ( please select all that apply): Recursion, For-loop

10. An instance of a class is an object: True

11. A class is a blueprint of an Obejct

12. Inheritance means; a class is derived from another class

13. Information Hiding means: hiding the internals of a class

14. The constructor function's return type is: no return type

15. A constructor is a special function that: instantiates a class

16. Sorry, I couldn't figure it out !

17. If you use the keyword virtual in a function declaration, the function may be overridden in derived classes: True

18. Any function declared as public may be overridden in subclasses: True

19. Mark everything that is inherited when a class derives from another class: public member functions, public member variables, static member functions

20. Which of the following is correct syntax for defining a new class AppleJuice based on the supper class SoftDrink?

class AppleJuice : public SoftDrink

21. What is the output of the following program?

class A{

       public:

       virtual void func() { cout<< "A"; }

};

class B: public A{

       public:

       void func() { cout << "B"; }

};

int main (){

       A * val = new B;

       val->func();

       return 0;

}

Output: B

22. If a base class has public member functions that are not listed by a derived class, then these functions: are inherited unchanged in the derived class

23. Polymorphism refers to: overloading functions, overriding base class functions

24. Assume a base class has a non-virtual member function named run(). If an object pointer ptrdeclared as the base class is pointing to an object of a derived class, then the code ptr->run( ); calls: the derived print function

25. Operators can be overloaded in C++: True

26. A default constructor cannot have more than _____ parameters: 0

28. In which case would you consider using a dynamic array?: If the program needs to get the size of the array from the user

29. If p1 and p2 are both pointers that point to integers in memory, the condition p1==p2 will be true if the values that are in those memory locations are the same: False

30. Please complete the following code to make sure that a user input is a positive number larger than 10.

#include <iostream>

using namespace std;

int main ()

{

int userInput;

cout << "Enter a number greater than 10: ";

cin >> userInput;

while(userInput < 10)

{

cout << "Enter a number greater than 10: ";

cin >> userInput;

}

cout << "User input: " << userInput << endl;

return 0;

}

**********************************************************************************************************************************************

Add a comment
Know the answer?
Add Answer to:
Question 1 2 pts The preprocessor executes after the compiler. False True Question 2 2 pts...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 1 10 pts Inheritance is a capability of C++ to represent increased specialization that is...

    Question 1 10 pts Inheritance is a capability of C++ to represent increased specialization that is often found in real world relationships. True False Question 2 10 pts Inheritance between a child and parent object exhibits an 'relationship. Question 3 10 pts As you move down an inheritance relationship from parent to child, you typically move from a general to specific description. True False Question 4 10 pts The syntax for declaring DerivedClass to publicly inherit from BaseClass is given...

  • In Exercise 1, displayAnimal uses an Animal reference variable as its parameter. Change your code to...

    In Exercise 1, displayAnimal uses an Animal reference variable as its parameter. Change your code to make the displayAnimal function anim parameter as an object variable, not a reference variable. Run the code and examine the output. What has changed? Polymorphic behavior is not possible when an object is passed by value. Even though printClassName is declared virtual, static binding still takes place because anim is not a reference variable or a pointer. Alternatively we could have used an Animal...

  • Answer this in c++ #include <iostream> #include <fstream> #include <string> using namespace std; class Person {...

    Answer this in c++ #include <iostream> #include <fstream> #include <string> using namespace std; class Person { public: Person() { setData("unknown-first", "unknown-last"); } Person(string first, string last) { setData(first, last); } void setData(string first, string last) { firstName = first; lastName = last; } void printData() const { cout << "\nName: " << firstName << " " << lastName << endl; } private: string firstName; string lastName; }; class Musician : public Person { public: Musician() { // TODO: set this...

  • D Question 18 4 pts A function template is an actual function that the compiler uses...

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

  • Create a base class and two derived classes. Also, create and call a member function named...

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

  • In Java Which of the following statements declares Salaried as a subclass of payType? Public class...

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

  • QUESTION 40 You create a class by writing a(n) ________. preprocessor directive class declaration code blueprint...

    QUESTION 40 You create a class by writing a(n) ________. preprocessor directive class declaration code blueprint object specification 2 points    QUESTION 41 You can think of a derived class as an extended version of some base class. True False 2 points    QUESTION 42 The DBMS works directly with the data and sends the results of operations back to the ________. data application CPU DBMS 2 points    QUESTION 43 Data-bound controls automatically display data from a data source...

  • Question 116 pts (TCO 2) What is the output of the following code?                         void func(int...

    Question 116 pts (TCO 2) What is the output of the following code?                         void func(int x)                         {                                     x = x * 2;                         } int main( ) {         int x = 10;         func(x);         cout << x << endl; } 20 30 10 5 Question 126 pts (TCO 2) A derived class is typically an example of _____. a “has a” relationship an “is a” relationship a “uses a” relationship an “is used” relationship Question...

  • 1.   What will be the value of x after the following code is executed? int x...

    1.   What will be the value of x after the following code is executed? int x = 10, y = 20; while (y < 100) { x += y; } A.   90 B.   110 C.   210 D.   This is an infinite loop 2.   If a superclass has constructor(s): A.   then its subclass must initialize the superclass fields (attributes). B.   then its subclass must call one of the constructors that the superclass does have. C.   then its subclass does not inherit...

  • Please submit the following files for this assignment: *****************Animal.h, Animal.cpp, Mammal.h, Mammal.cpp, Cat.h, Cat.cpp, main.cpp********* Assignment...

    Please submit the following files for this assignment: *****************Animal.h, Animal.cpp, Mammal.h, Mammal.cpp, Cat.h, Cat.cpp, main.cpp********* Assignment 4 – OOP – inheritances Create a base class Animal (Animal.h, Animal.cpp) Member variables (private): string name; string type; Member methods (public): Constructor(s) Setters Getters eat(); //display “Eat food.” Create a derived class Mammal from Animal (public) (Mammal.h, Mammal.cpp) Member variables (private): string hair_type; //eg: fur, hair,etc Member methods (public): Constructor(s) Setters Getters Create a derived class Cat from Mammal (public) (Cat.h, Cat.cpp) Member...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT