Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Zend Exam 200-710 Topic 2 Question 42 Discussion

Actual exam question for Zend's 200-710 exam
Question #: 42
Topic #: 2
[All 200-710 Questions]

What is the output of the following code?

class a

{

public $val;

}

function renderVal (a $a)

{

if ($a) {

echo $a->val;

}

}

renderVal (null);

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

Benedict
16 days ago
Wait, is this a trick question? What if the real answer is 'a syntax error, and then a crash and burn of the entire system'? Hmm, maybe I should just guess randomly.
upvoted 0 times
Deangelo
2 days ago
B) An error, because null is not an instance of 'a'
upvoted 0 times
...
...
Layla
18 days ago
This question is a real head-scratcher. I'm gonna go with option B, just because I don't trust passing null values to functions.
upvoted 0 times
...
Giovanna
20 days ago
Hold up, why is the function declaration using 'a $a' instead of just '$a'? Isn't that a syntax error? I'm gonna go with option A.
upvoted 0 times
Anjelica
1 days ago
It's not a syntax error, it's type hinting for the parameter. So, the function expects an object of class 'a'.
upvoted 0 times
...
...
Lynette
1 months ago
Ugh, I hate these tricky questions. But I think option C is the right answer. The function will just do nothing if a null value is passed in.
upvoted 0 times
Estrella
7 days ago
I agree, passing a null value will result in nothing happening.
upvoted 0 times
...
Lisha
20 days ago
I think option C is correct.
upvoted 0 times
...
...
Colby
1 months ago
Hmm, I'm going with option D. The function is checking if the $a parameter is truthy, and null is a falsy value, so it should output NULL.
upvoted 0 times
Teddy
2 days ago
Actually, I believe it will output NULL.
upvoted 0 times
...
Nelida
3 days ago
I agree, it should throw an error.
upvoted 0 times
...
Aleshia
19 days ago
I think it's option B. Null is not an instance of 'a'.
upvoted 0 times
...
...
Tanja
1 months ago
I'm pretty sure option B is the correct answer. Passing a null value to a function that expects an instance of a class will result in an error.
upvoted 0 times
...
Carman
2 months ago
I agree with Arlene, it should be an error.
upvoted 0 times
...
Arlene
2 months ago
I believe it's an error, because null is not an instance of 'a'.
upvoted 0 times
...
Kaitlyn
2 months ago
I think the output is NULL.
upvoted 0 times
...

Save Cancel