nerdexam
National_Instruments

200-500 · Question #192

In the following code, which class can be instantiated? 1 <?php 2 abstract class Graphics { 3 abstract function draw($im, $col); 4 } 6 abstract class Point1 extends Graphics { 7 public $x, $y; 8…

The correct answer is C. Point2. See the full explanation below for the reasoning.

Question

In the following code, which class can be instantiated? 1 <?php 2 abstract class Graphics { 3 abstract function draw($im, $col); 4 } 6 abstract class Point1 extends Graphics { 7 public $x, $y; 8 function __construct($x, $y) { 9 $this->x = $x; 10 $this->y = $y; 11 } 12 function draw($im, $col) { 13 ImageSetPixel($im, $this->x, $this->y, $col); 14 } 15 } 17 class Point2 extends Point1 { } 19 abstract class Point3 extends Point2 { } 20 ?>

Options

  • AGraphics
  • BPoint1
  • CPoint2
  • DPoint3
  • ENone, the code is invalid

How the community answered

(16 responses)
  • B
    6% (1)
  • C
    81% (13)
  • E
    13% (2)

Community Discussion

No community discussion yet for this question.

Full 200-500 Practice