Which of the following is wrong with regards to Out keyword

A) For Out parameters a variable can be passed which has not initialized
B) If Out parameters are not assigned a value with in the function body compiler throws error
C) The variable passed as a Out parameter must be static

Showing Answers 1 - 8 of 8 Answers

ishita

  • Jan 3rd, 2006
 

Ans-A

  Was this answer useful?  Yes

samiksc

  • Jan 10th, 2006
 

Both (A) and (B) are correct. Out parameter var need not be initialized and it must be assigned a value in the method.

  Was this answer useful?  Yes

samiksc

  • Jan 10th, 2006
 

Actually correct choice is (C) since the question asks for a WRONG statement regarding out parameters.

  Was this answer useful?  Yes

Sanjida123

  • Jun 4th, 2010
 

Let's see what is out?

Out is a keyword used to fill value to the  parameter named as out.

A) For Out parameters a variable can be passed which has not initialized - True

We can pass an uninitialized variable to the function as argument. So, what compiler does? Compiler pass this by reference instead of value.  In activation frame, compiler doesnot create a copy of the actual variable. It works on the actual variable. So, any modification in the function body on the out parameter will reflect to the actual variable.

B) If Out parameters are not assigned a value with in the function body compiler throws error - True

Before leaving the function body, the out parameter has to be filled with value. If not compiler throws error.  Why ?

If compiler doesn't throw error, and programmer tries to work on that value, then it will mislead to some unknown behaviour.

C) The variable passed as a Out parameter must be static - False

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions