- 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); }
22 Answers
+ 4
Output is 30
+ 2
answer is 30
+ 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
+ 1
equal 30
+ 1
30
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);
}
0
explain in detail what is role of out keyword here ?
0
answer-2
0
30
0
All of you are wrong its
7 šš
0
answer is 16
0
The correct answer is 3
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
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.
0
no kidding its 9
0
Ans is 30
0
Answer : 5
0
30 Ans
0
int
x
0
what is the output of this codeint x = 7 ; do { x ++ ; } while (x <= 9) ; Console.Write(x);??