basic physics
20 basic physics questions
1- Choose the best language construct to store a list of doubles when the length of the list is not known until the program runs.
Group of answer choices
a) structure (struct)
b) overloaded operator
c) template class
d) dynamic array
2- A user-defined Inventory class holds warehouse data stored on disk. In what source code file should member function
definitions for the class be placed?
Group of answer choices
main.cpp (main program)
fstream (header file from C++ library)
inventory.h (header file)
inventory.cpp (implementation file)
3- Examine the class below:
class Coordinate
{
public:
Coordinate(int startX, int startY);
int getX() const;
int getY() const;
private:
int x;
int y;
};
Select the best way to describe how to use the class to another programmer who knows C++.
Group of answer choices
Stores 2 private numeric values with 3 members functions, 2 of which are marked “const”.
Stores 2 ints of the same type named “x” and “y” as well as a constructor and 2 “get” member functions.
Stores a coordinate, allowing user to set up and acquire its values from the class.
Stores integer x, y coordinates initialized via a constructor, with accessor methods.
Question 4
1 pts
Which object-oriented programming feature(s) does the following class use?
class TrueFalseAnswer : public Answer
{
public:
void showChoices() override;
…
private:
bool correct;
};
Group of answer choices
inheritance
polymorphism
All of these features
encapsulation
5-
Consider the following function prototype:
void advertise(const Book& book);
Select the correct way to pass the Book in the function call below.
Book* bookP = new Book();
advertise(________);
delete bookP;
Group of answer choices
advertise(bookP[]);
advertise(bookP);
advertise(*bookP);
advertise(&bookP);