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
1 months 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
Adolph
2 days ago
C) Nothing, because a null value is being passed to renderVal()
upvoted 0 times
...
Clay
8 days ago
I think it's B
upvoted 0 times
...
Deangelo
17 days ago
B) An error, because null is not an instance of 'a'
upvoted 0 times
...
...
Layla
1 months 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
1 months 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
Ivette
1 days ago
Got it, thanks for the explanation!
upvoted 0 times
...
Ressie
8 days ago
Oh, I see. So, since null is not an instance of 'a', it will result in an error. Option B is correct.
upvoted 0 times
...
Anjelica
16 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
2 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
Phillip
9 days ago
Yeah, the function won't do anything with a null value.
upvoted 0 times
...
Estrella
22 days ago
I agree, passing a null value will result in nothing happening.
upvoted 0 times
...
Lisha
1 months ago
I think option C is correct.
upvoted 0 times
...
...
Colby
2 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
Tamar
3 days ago
You're right, null is falsy so it should output NULL.
upvoted 0 times
...
Teddy
17 days ago
Actually, I believe it will output NULL.
upvoted 0 times
...
Nelida
18 days ago
I agree, it should throw an error.
upvoted 0 times
...
Aleshia
1 months ago
I think it's option B. Null is not an instance of 'a'.
upvoted 0 times
...
...
Tanja
2 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
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77