- 4

What is the output of this code?

static int test(out int x,int y=4) { x=6; return x*y; } static void main (string []args) { int a; int z=test(out a); Console. WriteLine(out a+z); }

30th Nov 2016, 6:21 AM
Kowsalya A
Kowsalya A - avatar
22 Answers
+ 4
Output is 30
13th Jul 2019, 5:36 AM
Bruno Jose
Bruno Jose - avatar
+ 2
answer is 30
19th Jun 2017, 4:28 AM
Jayalakshmi.K
+ 1
You cant have a 'out' statement inside the Console.WriteLine as it is not a value and can't give a value to 'z', therefore the code is somehow wrong. But lets say we fix the error I added comments to make the code more readable and easier to understand. static int test(out int x,int y=4) { x=6; return x*y; //Test becomes 4x6, which is 24. } static void main (string []args) { int a; int z=test(out a); //a will become test, z will become 'a' Console. WriteLine(z); //outputs z } In short, this code should output a value of 24
30th Nov 2016, 6:33 AM
Wen Qin
Wen Qin - avatar
+ 1
equal 30
22nd Sep 2017, 9:58 AM
Hasan Al Moussawi
+ 1
30
20th Oct 2020, 11:06 AM
SURYA.T
SURYA.T - avatar
0
What is output of the code? static int test(out int x,int y=4) { x=6; return x*y; } static void main (string []args) { int a; int z=test(out a); Console. WriteLine(a+z); }
24th Jul 2017, 11:53 AM
Santosh Kumar Sinha
Santosh Kumar Sinha - avatar
0
explain in detail what is role of out keyword here ?
24th Jul 2017, 11:56 AM
Santosh Kumar Sinha
Santosh Kumar Sinha - avatar
0
answer-2
3rd Nov 2017, 2:53 PM
susmita Ojha
susmita Ojha - avatar
0
30
26th Dec 2017, 1:40 PM
Archana Kumari
Archana Kumari - avatar
0
All of you are wrong its 7 šŸ˜‚šŸ˜‚
9th Nov 2018, 2:05 AM
Seth Hawkins
Seth Hawkins - avatar
0
answer is 16
24th Jan 2019, 11:09 AM
nalluri venkata sandeep
nalluri venkata sandeep - avatar
0
The correct answer is 3
27th Mar 2019, 10:24 PM
Rinae Tshivhinda
Rinae  Tshivhinda - avatar
0
What is the output of this code? static int Test(out int x, int y=4) { x = 6; return x * y; } static void Main(string[] args) { int a; int z = Test(out a); Console.WriteLine(a + z); } In Main Function, Step: 1=> integer type variable 'a' is declared but no value initialized Step: 2=> interger type variable 'z' is declared and value is function returned a value 24. Step: 3=> add two values (a=6 + z=24) and writes answer is 30 Note: In Test Method have used Named Arguments. variable x is initialized and returned a calculated value is 6*4= 24 Output is 30
13th Jul 2019, 4:21 AM
Bruno Jose
Bruno Jose - avatar
0
public static void main(String[ ] args) { int x = 10; int y = myFunc(x); System.out.println(y); } public static int myFunc(int x) { return x*3; } 30 is the answer.
10th Oct 2019, 10:46 AM
Akshay Narkhede
0
no kidding its 9
24th May 2020, 12:07 PM
ULTIMATEKID
ULTIMATEKID - avatar
0
Ans is 30
21st Oct 2020, 11:35 AM
Rithik Tati
Rithik Tati - avatar
0
Answer : 5
26th Apr 2021, 3:42 PM
Mustafa Burak AYDIN
Mustafa Burak AYDIN - avatar
0
30 Ans
30th Apr 2022, 5:59 AM
MAREESWARAN S
MAREESWARAN S - avatar
0
int x
8th May 2022, 4:57 PM
Geethika Gayani Weerasinghe
0
what is the output of this codeint x = 7 ; do { x ++ ; } while (x <= 9) ; Console.Write(x);??
6th Jan 2023, 3:20 AM
Janice Taboy
Janice Taboy - avatar