Thursday, December 10, 2009

c++part3

UNIT III- Templates, Pointers and Graphics
One mark questions:

1. ____ is a variable that holds the address of a data item.
a. reference b. pointers c. Both a& b d. None

2.Graphics mode require a graphics monitor and _______.
a. CGA b. EGA c. VGA d. All

3. To include a user-defined header file you use ____.
a. “ “ b. < > c. Both d. None

4. Templates are also known as ___________.
a. abstract data types b. Parameterized data types c. Both a & b d. None

5. When the class derives another class, ______ template is written for derived class.
a. different b. same c. Cannot be done d. None

6.Addresses are basically starting with _______
a. 0 b. 1 c. –1 d. None

7.If 640K memory then ___ is max address.
a. 0 b. 65535 c. 65534 d. 65536

8. _______ operator is used to allocate memory.
a. malloc( ) b. new c. Both a & b d. None

9. ______ operator is used to deallocate memory
a. free ( ) b. delete c. Both d. None

10. At the ___________ data structure is concerned with the actual storage location of data and
the relationship of different data items.
a. Physical level b. Logical level c. Both d. None

11. At the ____ data structure is concerned with the defined data relationships.
a. Physical level b. Logical level c. Both d. None

12. Data structures have _______ levels.
a. 1 b. 2 c. 4 d. 0

13. Inside the class, we can create _____ of its own type but we cannot create ___ of its own
type.
a. Object, Pointer b. Pointer, Object c. array, object d. None

14. How do you declare array of pointers.
a. *p b. (*p)[2] c. *p[2] d. None

15. How do you declare pointer to pointers.
a. **p b. (*p)[2] c. *p[2] d. None

16. What is the meaning of **p ____
a. the address of a pointer is a pointer to a integer
b. the address of a pointer is a pointer to a pointer c. Not available d. None

17. ____ function erases the text window.
a. clrscr( ) b. cleardevice( ) c. Both d. None

18. _____ header file is included for working with graphics.
a. stdio.h b. graphics.h c. windows.h d. None

19. _____ function positions the cursor within the text window.
a. move( ) b. gotoxy( ) c.moveto( ) d. None

20. _____ function releases the memory of graphics system.
a. close ( ) b. closegraph( ) c. Both a & b d. None

21. ____ function fills a bounded region with color.
a. setcolor( ) b. floodfill c. fillcolor( ) d. None

22. The viewports arguments are given in _____ coordinates
a. absolute screen b. graphics c. Cartesian d. None

23. If the value of the setviewport “clip” argument is set to ___, then all drawings will be clipped
the current viewport.
a. 0 b. non- zero c. Both d. None

Two mark Questions

1. Turbo C++ graphics functions can be categorized as
a) text mode only b. graphics mode only c. Both text and graphics d. None

2. Which of the following are true for template classes:-
i) Use the statement “template ” before the class
ii) Use the statement “template ” before the main( )
iii) T stands for new class
iv) T is name given instead of the data type for declaring private variables of the class.
a) I, iii b. I, iv c. ii, iii d. ii, iv

3. Which of the following are advantages of “new” operator:
i) It is superior to malloc in C
ii) Its return value needs to be casted
iii) it returns a pointer to appropriate data type
a. I,ii b. I , iii c. All d. None

4. Which of the following is true for “delete” operator.
i) It deletes the pointer that points to it
ii) It does not change the address value in the pointer
iii) The address is no longer valid
iv) the memory it points to holds the same value as before.
a. ii, iii b. I, ii, iii c. All d. None

5. Which of the following is true about linked list:
i) It is a data structure
ii) Each element is said to be a node
iii) Every element (node) contains data and pointer to next location
iv) the last node pointer contains NULL
a. only ii, iii b. Only I, iv c. All d. None

6. Which of the following are advantages of using linked list
i) It can be allocated when required
ii) It has fixed memory allocation
iii) It is more flexible storage
a. I, iii b. ii. iii c. All d. iii

7. Which of the following operations can be performed with single linked list:
i) create list ii) insert iii) delete iv) change
v) move forward vi) move backward
a. I, ii, iii, v b. I, ii, iii, iv, v c. All d. None

8. Which of the following can be performed with double linked list
i) create list ii) insert iii) delete iv)change
v) move forward vi) move backward
a. I, ii, iii, v b. I, ii, iii, iv, v c. All d. None

9. Which of the following are the valid attributes for the fillstyle patterns:
i) SOLID_FILL ii) SOLID_LINE iii) SLASH_FILL iv) HATCH_FILL
v) USER_FILL vi) DOT_FILL
a. I, iii, iv, v b. I, iii, iv, v, vi c. All d. None

10. Which of the following are valid values for settextjustify vertical alignments:
i) LEFT_TEXT ii) CENTER_TEXT iii) RIGHT_TEXT
iv) BOTTOM_TEXT v) TOP_TEXT
a. I, ii, iii b. ii, iv, v c. All d. None

11. Which of the following are valid values for settextjustify horizontal alignments:
i) LEFT_TEXT ii) CENTER_TEXT iii) RIGHT_TEXT
iv) BOTTOM_TEXT v) TOP_TEXT
a. I, ii, iii b. ii, iv, v c. All d. None

Four mark Questions

1. In which of the following areas pointers are used:
i) Accessing array elements
ii) Passing address arguments to functions when the function needs to modify the original
arguments
iii) passing arrays and strings to functions
iv) obtaining memory from the system- Dynamic memory allocation.
v) creating data structures such as linked list
a. ii, iii, iv b. I, ii, v c. All d. None

2. Read the program
template
class stack
{
T st[MAX];
Int top;
Public:
stack(){ top= -1;}
void push(T var){ st[++top]=var; }
T pop( ){ return st[top--]); }
};
void main( )
{
? ss;

ss.push(‘G’);

}
To create an object which can take characters what statement should be replaced for ?
a. stack b. stack c. stack d. None

3. Match the following:
1) cleardevice ( ) I) positions the cursor at a position in graphics screen
2) clrscr( ) ii) clears the graphical screen
3) gotoxy( ) iii) positions the cursor in text window
4) moveto ( ) iv) clears the text window
a. 1- ii, 2- iv, 3- iii, 4- I b. 1- iii, 2- iv 3- ii, 4 – I c. 1- I, 2- ii, 3- iii, 4- iv d. 1- iv, 2- iii, 3- ii,4-I

4.Which of the following is the correct syntax of circle()
a. circle( int col, int row, int radius)
b. circle( int row,int col, int radius)
c. circle( int col, int row,int radius, int color)
d. circle(int row, int col, int radius, int color)

5. Match the functions with number of their arguments
1) line( ) I) int col, int row, int haxis, int vaxis
2) arc( ) ii) int col, int row, int stangle, int e_angle,int hor_rad,int ver_rad
3) ellipse( ) iii) int col,int row, int stangle, int eangle, int rad
4) fillellipse( ) iv) int col,int row,int col, int row
a. 1-ii, 2-iv, 3- iii, 4- I b. 1-iii, 2- iv,3- ii, 4-I c. 1-I,2-ii, 3-iii, 4- iv d. 1-iv,2-iii, 3- ii,4-I

6.Match the functions with their functionality
1) getx( ) I) returns the number of pixels in each row
2) getpixel( ) ii) returns the x coordinate
3) getmaxx( ) iii) plots the pixel at the specified location
4) putpixel( ) iv) returns an integer representing the colour of the pixel
a. 1- ii, 2- iv, 3- I, 4- iii b. 1-I, 2-ii, 3- iii, 4- iv c.1- iii, 2- I, 3-iv, 4- ii d. 1- iv,2- iii, 3- ii, 4- I

7. Match the functions with their functionality
1) detectgraph( ) I) It initializes the graphics system
2) initgraph( ) ii) releases memory of graphics system
3) cleardevice( ) iii) checks the system for graphics
4) closegraph( ) iv) clears the graphics window and places the cursor in (0,0)
a. 1-ii, 2- iv, 3- I, 4- iii b. 1-1, 2-ii, 3- iii, 4- iv c. 1- iii, 2- I, 3- iv, 4- ii d. 1-iv, 2- iii, 3-ii, 4- i





Answers
One mark
1. b 11.b 21.b
2. d 12.b 22.a
3. a 13.b 23.b
4.b 14.c
5.a 15.a
6.a 16.b
7.b 17.a
8.b 18.b
9.b 19.b
10.a 20.a
two mark
1. c 11.a
2. b
3. b
4.a
5.c
6.a
7.b
8.c
9.a
10.b
four mark
1. c
2. b
3. a
4.a
5.d
6.a
7.c