Q:
C#.Net find output programs (Method Overriding) | 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 created three classes Parent, Child, and Program. Here, Parent class inherited in Child class. Both Parent and Child class contains the Print() method.
Now look to the Main() method of Program class, Here we created the object P of Parent class and then call Print() method, then it will call the Print() method of Parent class,
P = new Child();
Using the above statement we re-initialized the P using Child class. Then we called the Print() method, it will call the Print() method of Parent class again. If we want to override the method in Child class then we need to use virtual and override keywords.
Answer 2:
Output:
Explanation:
The above program will generate syntax error because we used the override keyword in the Parent class method. We can use the override method in child class only. Because we can override existing parent class method in child class.
Answer 3:
Output:
Explanation:
In the above program, we created three classes Parent, Child, and Program. Here, Parent class inherited in Child class. Both Parent and Child class contains the Print() method. We used the virtual keyword in the Parent class method and override keyword in Child class.
Now look to the Main() method of Program class, Here we created the object P of Parent class and then call Print() method, then it will call the Print() method of Parent class.
P = new Child();
Using the above statement we re-initialized the P using Child class. Then we called the Print() method, it will call the Print() method of Parent class again. If we want to override the method in Child class then we need to use virtual and override keywords.
Answer 4:
Output:
Explanation:
In the above program, we created three classes Parent, Child, and Program. Here, Parent class inherited in Child class. Both Parent and Child class contains the Print() method.
Now look to the Main() method of Program class, Here, we created the object P of Parent class and then call Print() method, then it will call the Print() method of Parent class.
P = new Child();
Using the above statement we re-initialized the P using Child class. Then we called the Print() method, it will call the Print() method of Parent class again. If we want to override the method in Child class then we need to use virtual and override keywords.
Answer 5:
Output:
Explanation:
The above program will generate syntax error because we did not define the Print() method in Parent class. That's why errors will be generated in the above program.
need an explanation for this answer? contact us directly to get an explanation for this answer