Question: The square and Triangle classes shown above will be used for remainder of the questions. 9 . Which code snippet correctly implements the parametrized A
The square and Triangle classes shown above will be used for remainder of the questions.
Which code snippet correctly implements the parametrized A Square constructor which takes in x y and side?
Squarefloat x float y float side this side side;
B Squarefloat x float y float side : Shapex y this side side;
C Squarefloat x float y float side this x x; this y y; this side side;
D All of the above
E Only B and C
Which code snippet correctly implements the draw method for the Square class?
A void draw
glColorfcolorr color.g color.b;
glBeginGLPOLYGON; glVertexfgetX getY; glVertexfgetX side, getY; glVertexfgetX side, getY side; glVertexfgetX getY side;
glEnd ;
B void draw
glColorfcolorr color.g color.b;
glBeginGLPOLYGON;
glVertexfx y;
glVertexfx side, y; glVertexfx side, y side; glVertexfx y side;
glEnd ;
C void draw
Color c getColor ;
glColorfcr cg cb;
glBeginGLPOLYGON; glVertexfgetX getY; glVertexfgetX side, getY; glVertexfgetX side, getY side; glVertexfgetX getY side;
glEnd ;
D All of the above
E Only A and C
Which code snippet correctly implements the parametrized Triangle constructor which takes in x y base, and height?
A Trianglefloat x float y float base, float height
setXx;
setYy;
this base base; thisheight height;
B Trianglefloat x float y float base, float height : Shapexy
this base base;
thisheight height;
C Trianglefloat x float y float base, float height
this x x;
this y y; thisbase thisheight;
D All of the above
E Only A and B
Which code snippet correctly implements the parametrized Triangle constructor which takes in x y and color?
A Trianglefloat x float y Color color this x x;
this y y; thiscolor color; base f;
height f;
B Trianglefloat x float y Color color setXx;
setYy; setColorcolor; base f; height f;
C Trianglefloat x float y Color color : Shapex y thiscolor color; base f; height f;
D Trianglefloat x float y Color color : Shapex y color base f; height f;
E All of the above, except A
Which of the following statements is false?
A Triangle publicly inherits from Shape.
B Square publicly inherits from Shape.
C Shape is the parent of both Triangle and Square
D Triangle and Square need to implement their own draw method. E All of the above statements are true.
Which data members of Shape are accessible to Triangle and Square? A xandy
B color
C x y and color D None of the above
Which code snippet correctly creates an instance of Square, not on the heap?
A Square square new Square;
B Square square Square ;
C Shape shape new Square;
D Shape shape Square ;
E Both B and D
Which code snippet correctly creates an instance of Triangle on the heap?
A Triangle triangle new Triangle;
B Triangle triangle Triangle ;
C Shape shape new Triangle;
D Shape shape Triangle ;
E Both A and C
Which code snippet correctly creates an array of Squares of size on the heap?
A Square squares;
B Square squares new Square;
C Square squares ;
D Square squares;
E Both A and B
Which code snippet correctly releases the memory from the previous question?
A delete squares;
B delete squares;
C for int i ; i ; i delete squaresi;
D for int i ; i ; i delete squaresi; delete squares;
E None of the above
Which code snippet correctly creates an array of Shape pointers of size
A Shape shapes ;
B Shape shapes ;
C Shape shapes new Shape ;
D Shape shapes new Shape ;
E Both C and D
Which code snippet correctly releases the memory from the previous question?
A delete shapes;
B delete shapes;
C for int i ; i ; i delete shapesi;
D for int i ; i ; i delete shapesi; delete shapes;
E None of the above
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
