100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

ICT3612 EXAM PACK 2025 {DETAILED QUESTIONS AND ANSWERS }

Rating
-
Sold
-
Pages
85
Grade
A+
Uploaded on
16-11-2024
Written in
2024/2025

ICT3612 EXAM PACK 2025 {DETAILED QUESTIONS AND ANSWERS }

Institution
Course











Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Course

Document information

Uploaded on
November 16, 2024
Number of pages
85
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

lOMoAR cPSD| 49343224




Downloaded by Vincent master ()

, lOMoAR cPSD| 49343224




THIS DOCUMENT CONTAINS 200+ ANSWERED QUESTIONS
Question 1 (2 marks)
What is the output of the following code
when executed? function func_1(){
return "func_1 is executed";
}
function
func_2()
{
func_1()
;
echo "func_2 is executed";
}

f
u
n
c
_
2
(
)
;

1. func_1 is executedfunc_2 is executed
2. func_1 is executed
3. func_2 is executed
4. func_2 is executedfunc_1 is executed

Answer: (3)
Refer to chapter 13.
Both functions get executed, however the string returned by func_1()
never gets displayed.




Downloaded by Vincent master ()

, lOMoAR cPSD| 49343224




Question 2 (2 marks)
What is the output displayed by the
following code? function
calculate($arr, &$num){
$result
= 0;
foreach($arr
as $value){
$result += $value;
}
$num = $result / count($arr);
}

$arr = array(10,20,30,40,50);
$num =
0;
calcul
ate($a
rr,$nu
m);
echo
$num;

1. 150
2. 30
3. 15
4. 0

Answer: (2)
Refer to pages 392 to 393 (section ‘How to pass arguments by value
and by reference’) in chapter 13. In this code $num is passed by
reference and in the function, it gets initialised to 30
((10 + 20 + 30 + 40 + 50)/5), which then displayed outside of the
function.

Question 3 (2 marks)
What is the output
displayed by the following
code? function
calculate(){ $num
= func_num_args();
$result = 0;




Downloaded by Vincent master ()

, lOMoAR cPSD| 49343224




for($i = 0; $i <
$num; $i++){ $result
+= func_get_arg($i);
}
return $result * $num;
}
echo calculate(3,2,1,0);

1. 0
2. 7
3. 21
4. 24

Answer: (4)
Refer to pages 400 to 401 (section ‘How to use variable-length
parameter lists’) in chapter 13. The function makes use of variable-
length parameter lists. It adds all the arguments and multiplies the sum
by the number of passed arguments. So 3+2+1+0 is 6 and 6*4 is 24.
Question 4 (1 mark)
Within a function, you can use the ________________ keyword if you
need to refer to a variable that’s declared outside the function.

1. global
2. return
3. arguments
4. void

Answer: (1)
Refer to pages 394 to 395 (section ‘How variable scope works’)
in chapter 13. Question 5 (2 marks)

Which of the following options is correct about functions in PHP?

1. One can define a function without a name. Similarly, one can
define a function without a return statement.
2. When an argument is passed by value, the original variable is
sent to the function. Then any changes to the parameter in the function
causes changes in the value stored in the original variable.
3. If a function is defined without any parameters, it means that no
arguments can be passed to the function when a function call is made.
4. A dedicated PHP file can be created to define multiple functions
but a namespace must be created for the functions in the file.

Answer: (1)




Downloaded by Vincent master ()

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
MasterVincent University of South Africa (Unisa)
Follow You need to be logged in order to follow users or courses
Sold
2569
Member since
2 year
Number of followers
452
Documents
1531
Last sold
4 days ago
MasterVincent

On this page, you find all documents, package deals, and flashcards offered by seller MasterVincent.

4.1

379 reviews

5
206
4
69
3
51
2
24
1
29

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions