Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question
4. What is the output of the following program:
void fun (int n) {
}
cout << n;
if (n = 3)
return;
fun (n+1);
cout << n;
a. 12
b. 132
c. 12321
d. 1234
vector <int> v2 = {3};
v2 = v1;
e. 12345
5. Consider the following code segment, and select the best answer:
vector <int> vl =
(11, 23, 99};
for (int i = 0; i < 3; i++)
cout << v2.at (i) << " ";
The output will be:
a. 11 23 99
b. 3 23 99
int main()
{
}
a. This code gives a compilation error on the second line.
b. This code prints 6.
c. This code prints -6.
d. None of the above
fun (1);
return 0;
c. 3
d. There will be no output due to improper assignment operation in the
third line.
6. Consider the following code segment. Which one of the following statements is true?
string s1 = "893";
s1 += "99";
int y = s1.at (2) sl.at (4);
cout << y;
expand button
Transcribed Image Text:4. What is the output of the following program: void fun (int n) { } cout << n; if (n = 3) return; fun (n+1); cout << n; a. 12 b. 132 c. 12321 d. 1234 vector <int> v2 = {3}; v2 = v1; e. 12345 5. Consider the following code segment, and select the best answer: vector <int> vl = (11, 23, 99}; for (int i = 0; i < 3; i++) cout << v2.at (i) << " "; The output will be: a. 11 23 99 b. 3 23 99 int main() { } a. This code gives a compilation error on the second line. b. This code prints 6. c. This code prints -6. d. None of the above fun (1); return 0; c. 3 d. There will be no output due to improper assignment operation in the third line. 6. Consider the following code segment. Which one of the following statements is true? string s1 = "893"; s1 += "99"; int y = s1.at (2) sl.at (4); cout << y;
15. In a C or C++ program, header files normally do NOT contain:
a. include directives
b. constants
C. struct definitions
d. function prototypes
e. function definition/implementation
16. Consider the following code segment that dynamically allocates memory on the heap to create and use it as a
matrix with 4 rows, and 3 columns:
int **a = new int* [4];
for (int i = 0; i <4; i++) {
}
Which one of the following statements is the proper way to de-allocate/remove the allocated memory from heap:
for (int i= 0; i < 3; i++)
delete [ a[i];
a
b
с
a[i] = new int [3];
for (int j=0; j < 3; j++)
a[i] [j] = 0;
delete [] a;
delete [] a;
for (int i = 0; i < 4; i++)
delete [] a [i];
for (int i = 0; i < 4; i++)
delete [] a[i];
delete [] a;
d delete [] a;
};
Consider the following definition of class Box and main function. Assuming constructor, copy constructor,
assignment operator, and destructor of this class are properly without any error implemented, answer the
following four questions:
class Box {
public:
Box();
~Box ();
Box (const Box & source);
Box& operator= (const Box & rhs);
private:
int* pointer;
int main (void) {
Box x;
Box y (x);
Box *z = new Box;
x = y;
return 0;
17. How many times the constructor of class Box is called?
Once
a.
b. Twice
c. Three times
d. None of the above
18. How many times the copy-constructor of class Box is called?
a. Once
b. Twice
c. Three times
d. None of the above
20. How many times destructor of class Box is called
}
a. Once
b. Twice
c. Three times
d. None of the above
19. How many times assignment operator of class Box is called
a. Once
b. Twice
c. Three times
d. None of the above
m reaches point 1, for the second
expand button
Transcribed Image Text:15. In a C or C++ program, header files normally do NOT contain: a. include directives b. constants C. struct definitions d. function prototypes e. function definition/implementation 16. Consider the following code segment that dynamically allocates memory on the heap to create and use it as a matrix with 4 rows, and 3 columns: int **a = new int* [4]; for (int i = 0; i <4; i++) { } Which one of the following statements is the proper way to de-allocate/remove the allocated memory from heap: for (int i= 0; i < 3; i++) delete [ a[i]; a b с a[i] = new int [3]; for (int j=0; j < 3; j++) a[i] [j] = 0; delete [] a; delete [] a; for (int i = 0; i < 4; i++) delete [] a [i]; for (int i = 0; i < 4; i++) delete [] a[i]; delete [] a; d delete [] a; }; Consider the following definition of class Box and main function. Assuming constructor, copy constructor, assignment operator, and destructor of this class are properly without any error implemented, answer the following four questions: class Box { public: Box(); ~Box (); Box (const Box & source); Box& operator= (const Box & rhs); private: int* pointer; int main (void) { Box x; Box y (x); Box *z = new Box; x = y; return 0; 17. How many times the constructor of class Box is called? Once a. b. Twice c. Three times d. None of the above 18. How many times the copy-constructor of class Box is called? a. Once b. Twice c. Three times d. None of the above 20. How many times destructor of class Box is called } a. Once b. Twice c. Three times d. None of the above 19. How many times assignment operator of class Box is called a. Once b. Twice c. Three times d. None of the above m reaches point 1, for the second
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education