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

  • #code for creature.cpp #include <iostream> using namespace std; class Creature { public: Creature(); void run() const;...

    #code for creature.cpp #include <iostream> using namespace std; class Creature { public: Creature(); void run() const; protected: int distance; }; Creature::Creature(): distance(10) {} void Creature::run() const { cout << "running " << distance << " meters!\n"; } class Wizard : public Creature { public: Wizard(); void hover() const; private: int distFactor; }; Wizard::Wizard() : distFactor(3) {} void Wizard::hover() const { cout << "hovering " << (distFactor * distance) << " meters!\n"; } //Created new derived class from Creature class Widget...

  • C++ Programming QUESTION 10 Based on the following C++ code, what is the output of "pvari->print("...

    C++ Programming QUESTION 10 Based on the following C++ code, what is the output of "pvari->print(" function call? class A public void print cout << "Hello from A": 1 virtual void print2() {cout << "Hello from A2";} class B public A public void print) { cout << "Hello from B:1 virtual void print2() {cout << "Hello from B2": 1 int main() Avari Apvarl-new B; return 0; 1 o a Hello from A2 ob Hello from B O Hello from A...

  • True /False 13. _There is only one copy of the class's member func- tions and that...

    True /False 13. _There is only one copy of the class's member func- tions and that copy is shared among all the class's objects 14. Putting class definition in a separate file (e-g. head- er) makes it easy to reuse. 15. _A private data member of a class can usually be accessed from outside the class. 16. A member function of a class can call other private member functions of the same class. 17. _A destructor function can have parameters....

  • Question 22 4 pts In the statement: Int'. p and q are pointer variables. True False...

    Question 22 4 pts In the statement: Int'. p and q are pointer variables. True False D Question 23 4 pts If a user-defined class object that uses mathematical operators to pass to the template function, the class must contain code for the primitive data types the constructor the overloaded operators the try/catch blocks Question 24 4 pts Afriend function is a function that is not part of a class but has access to the class's private members as well...

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

  • C++ Could you check my code, it work but professor said that there are some mistakes(check...

    C++ Could you check my code, it work but professor said that there are some mistakes(check virtual functions, prin() and others, according assignment) . Assignment: My code: #include<iostream> #include<string> using namespace std; class BasicShape { //Abstract base class protected: double area; private:    string name; public: BasicShape(double a, string n) { area=a; name=n; } void virtual calcArea()=0;//Pure Virtual Function virtual void print() { cout<<"Area of "<<getName()<<" is: "<<area<<"\n"; } string getName(){    return name; } }; class Circle : public...

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
ADVERTISEMENT