Q:
C#.Net find output programs (default Arguments) | set 1
belongs to collection: C#.Net find output programs
C#.Net find output programs
- C#.Net find output programs (Data Types) | set 1
- C#.Net find output programs (Data Types) | set 2
- C#.Net find output programs (Data Types) | set 3
- C#.Net find output programs (Operators) | set 1
- C#.Net find output programs (Operators) | set 2
- C#.Net find output programs (Operators) | set 3
- C#.Net find output programs (const Keyword) | set 1
- C#.Net find output programs (this Keyword) | set 1
- C#.Net find output programs (readonly Keyword) | set 1
- C#.Net find output programs (static Keyword) | set 1
- C#.Net find output programs (static Keyword) | set 2
- C#.Net find output programs (if else) | set 1
- C#.Net find output programs (if else) | set 2
- C#.Net find output programs (if else) | set 3
- C#.Net find output programs (switch statement) | set 1
- C#.Net find output programs (switch statement) | set 2
- C#.Net find output programs (switch statement) | set 3
- C#.Net find output programs (goto) | set 1
- C#.Net find output programs (Loops) | set 1
- C#.Net find output programs (Loops) | set 2
- C#.Net find output programs (Loops) | set 3
- C#.Net find output programs (Arrays) | set 1
- C#.Net find output programs (Arrays) | set 2
- C#.Net find output programs (Arrays) | set 3
- C#.Net find output programs (default Arguments) | set 1
- C#.Net find output programs (default Arguments) | set 2
- C#.Net find output programs (Parameter Passing) | set 1
- C#.Net find output programs (Enumeration) | set 1
- C#.Net find output programs (Enumeration) | set 2
- C#.Net find output programs (Boxing & Unboxing) | set 1
- C#.Net find output programs (Structure) | set 1
- C#.Net find output programs (Structure) | set 2
- C#.Net find output programs (Structure) | set 3
- C#.Net find output programs (Classes & Objects) | set 1
- C#.Net find output programs (Classes & Objects) | set 2
- C#.Net find output programs (Classes & Objects) | set 3
- C#.Net find output programs (Constructors & Destructors) | set 1
- C#.Net find output programs (Constructors & Destructors) | set 2
- C#.Net find output programs (Constructors & Destructors) | set 3
- C#.Net find output programs (Inheritance) | set 1
- C#.Net find output programs (Inheritance) | set 2
- C#.Net find output programs (Inheritance) | set 3
- C#.Net find output programs (Interface) | set 1
- C#.Net find output programs (Interface) | set 2
- C#.Net find output programs (Method Overloading) | set 1
- C#.Net find output programs (Method Overloading) | set 2
- C#.Net find output programs (Method Overriding) | set 1
- C#.Net find output programs (Method Overriding) | set 2
- C#.Net find output programs (Method Overriding) | set 3
- C#.Net find output programs (Operator Overloading) | set 1
- C#.Net find output programs (Operator Overloading) | set 2
- C#.Net find output programs (Operator Overloading) | set 3
- C#.Net find output programs (Namespace) | set 1
- C#.Net find output programs (Namespace) | set 2
- C#.Net find output programs (Exception Handling) | set 1
- C#.Net find output programs (Exception Handling) | set 2
- C#.Net find output programs (Exception Handling) | set 3
Answer 1:
Output:
Explanation:
In the above program, we create a class Program that contains two static methods fun() and Main().
The method fun() contains three arguments a, b, and c. Here, argument c is used as a default argument. It means if we did not pass the value 3rd argument in the method fun(), then it takes value 30 for argument c by default.
Now coming to the Main() method, this is an entry point for program execution.
fun(10, 20, 40);
The above method call will print "A: 10, B: 20, C: 40" on the console screen.
fun(10, 20);
The above method call will print "A: 10, B: 20, C: 30" on the console screen.
Answer 2:
Output:
Explanation:
The above program will generate syntax error because default parameters must be trailing parameters in C#.
Answer 3:
Output:
Explanation:
In the above program, we create a class Program that contains two static methods fun() and Main().
The method fun() contains three arguments a, b, and c. Herem arguments b and c are used as default arguments. It means if we did not pass the values of 2nd or 3rd argument in the method fun(), then it takes use default values.
Now coming to the Main() method, this is an entry point for program execution,
fun(10, 20, 40);
The above method call will print "A: 10, B: 20, C: 40" on the console screen.
fun(10, c:20);
The above method call will print "A: 10, B: 50, C: 20" on the console screen. Here, we used the default value of argument b.
Answer 4:
Output:
Explanation:
In the above program, we create a class Program that contains two static methods fun() and Main().
The method fun() contains three arguments a, b, and c. Here, arguments b and c are used as default arguments. It means if we did not pass the values of 2nd or 3rd argument in the method fun(), then it takes use default values.
Now coming to the Main() method, this is an entry point for program execution,
fun(10, 20, 40);
The above method call will print "A: 10, B: 20, C: 40" on the console screen,
fun(10, b:20);
The above method call will print "A: 10, B: 20, C: 80" on the console screen. Here, we used the default value of argument c.
Answer 5:
Output:
Explanation:
In the above program, we create a class Program that contains two static methods fun() and Main() and we also defined a constant VAL that contains value 10, which is used as a default value for argument c in fun() method.
The method fun() contains three arguments a, b, and c. Here, arguments b and c are used as default arguments. It means if we did not pass the values of 2nd or 3rd argument in the method fun(), then it takes use default values.
Now coming to the Main() method, this is an entry point for program execution,
fun(10, 20, 40);
The above method call will print "A: 10, B: 20, C: 40" on the console screen,
fun(10, b:20);
The above method call will print "A: 10, B: 20, C: 10" on the console screen. Here, we used the default value of argument c.
need an explanation for this answer? contact us directly to get an explanation for this answer