Professional Documents
Culture Documents
Semester 1
Questions on Theory
Semester 1
Questions on Theory
Introduction to Programming II
COS1512
School of Computing
Dear Student
Below are a number of questions to assist you with your preparation with the theory aspects
of C++. Please attempt to answer the questions before looking at the given answers. Ensure
that you understand these concepts.
COS1512/2014
Semester 1
Questions on Theory
1. What is a pointer?
2. What is a dereferencing operator?
3. What is the difference between
p1=p2;
and
*p1 = *p2;
4. What is a dynamic variable?
5. What is the purpose of the new operator?
6. What is the purpose of the delete operator?
7. What is the freestore (also called the heap)?
8. What is the difference between dynamic variables and automatic variables?
9. What is a dynamic array?
10. What is the advantage of using dynamic arrays?
11. What is the relationship between pointers and arrays?
12. Write statements to do the following:
a. Define a pointer type int_ptr for pointer variables that contain pointers to int
variables.
b. Declare p1 to be a pointer to an int.
c. Dynamically allocate an integer variable and store its address in p1.
d. Assign the value 23 to the variable that p1 is pointing to.
e. Declare an int variable a.
f. Let p1 point to a.
2
COS1512/2014
Semester 1
Questions on Theory
f. Assume p2 has been initialized and copy the elements of p2 one by one to the
corresponding elements in a.
g. Free the memory allocated to the variable that p2 is pointing to.
14. What is the purpose of the keywords public and private in the class declaration?
15. What is the difference between a class and an object?
16. What does it mean to ‘instantiate’ an object?
17. What is the purpose of a constructor?
18. What is the difference between the default constructor and the overloaded constructor?
19. What is the purpose of a destructor?
20. What is the purpose of an accessor?
21. What is the purpose of a mutator?
22. What is the purpose of the scope resolution operator?
23. What is the difference between the scope resolution operator and the dot operator?
24. What is the difference between a member function and an ordinary function?
25. What is an abstract data type (ADT)?
26. How do we create an ADT?
27. What are the advantages of using ADTs?
28. What is separate compilation?
29. What are the advantages of separate compilation?
30. What is a derived class?
31. What is the purpose of inheritance?
©
Unisa
2014