Q:
C#.Net find output programs (Method Overloading) | set 2
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 overloaded the Addition() method based on different types of arguments.
In the Main() method we created the object of Program class and call both overloaded methods that will print the additions of given arguments on the console screen.
P.Addition(10, 20.5); P.Addition(10, 21.5);
Both the above method call will call the method with the argument of double type because, To call the method with the decimal argument we need to pass the second argument with the suffix 'M', the correct method call with the decimal argument is given below,
P.Addition(10, 21.5M);
Answer 2:
Output:
Explanation:
The above program will generate a compile-time error. In the above program, we overloaded the Addition() method based on different types of arguments. Here, the First method is used integer argument and the second method used arguments of long type.
In the above method, x and y are "long" type but z is "int" type. And the addition of long values cannot be assigned in the "int" variable in C#.
Answer 3:
Output:
Explanation:
The above program will generate compile-time errors. In the above program, we overloaded the Addition() method based on different types of arguments. Here, the First method is used integer argument and the second method used arguments of short type.
P.Addition(10H, 21H);
The above method call used 'H' as a suffix but it is not valid that's why compile-time errors are generated.
Answer 4:
Output:
Explanation:
In the above program, we created three classes A, B, and Program. Both A and B class contains the Addition() method with different types of arguments. Here, class A is inherited in class B.
B X = new B(); X.Addition(10, 20); X.Addition(10.25F, 11.25F);
In the Main() method of Program class we created an object of class B. Here, both above method calls will execute Addition() method of class B.
Answer 5:
Output:
Explanation:
The above program will generate compile-time errors. In the above program, we created three class A, B, and Program. Both A and B class contains the Addition() method with different types of argument.
Here class A is inherited in class B.
In the Main() method of Program class we created an object of class A. But the Addition() method of the class A can accept integer arguments only. But here we called a method with float arguments that's why compile-time errors will be generated by the above program.
need an explanation for this answer? contact us directly to get an explanation for this answer