Q:
C#.Net find output programs (Inheritance) | 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 created two classes ABC and XYZ. Here, we inherited class ABC into class XYZ.
Class ABC contains a destructor and a method FUN(), and class XYZ also contains a destructor.
Now look to the Main() method, the Main() method of Program class is the entry point of the program. Here, we created the object of class XYZ then here we called FUN() method. After the destructor of the XYZ, class gets called and then the destructor of ABC class called.
Answer 2:
Output:
Explanation:
In the above program, we created two classes ABC, PQR, and XYZ. Here, we inherited class ABC into class PQR class then we inherited PQR class into XYZ class.
Class ABC contains a destructor and a method FUN(), and class PQR and XYZ also contains a destructor.
Now look to the Main() method, The Main() method of Program class is the entry point of the program. Here, we created the object of class XYZ then here we called FUN() method. After destructors of XYZ, PQR, and ABC classes called respectively.
Answer 3:
Output:
Explanation:
In the above program, we created three classes ABC, PQR, and Program. The ABC class contains two protected members A and B that are initialized in the constructor with 10 and 20 respectively. Here, we inherited class ABC into class PQR. The PQR class contains a destructor that modifies the value of A and B members of class ABC.
Now look to the Main() method of Program class. Here, we created object X of PQR class then data members A and B initialized with 10 and 20. Then we called the Print() method that will print the value of A and B on the console screen. After that when the scope of class PQR gets finished then the destructor of class PQR gets called.
Answer 4:
Output:
Explanation:
In the above program, we created three classes ABC, PQR, and Program. The ABC class contains two protected members A and B that are initialized in the constructor with 10 and 20 respectively. Here, we inherited class ABC into class PQR. The PQR class contains a destructor. Here, Print() method is implemented in both classes ABC and PQR that will print values of A and B on the console screen.
Now look to the Main() method of Program class. Here, we created object X of PQR class then data members A and B initialized with 10 and 20. Then we called the Print() method that will print the value of A and B on the console screen. Here, Print() method of PQR class gets called because ABC and PQR both contain the method with name Print(). After that when the scope of class PQR gets finished then the destructor of class PQR gets called.
Answer 5:
Output:
Explanation:
The above program will generate a syntax error because we used super to call the Print() method of the superclass in the Print() method of PQR class. In C# super does not exist. To call the base class method we need to use the base keyword in the C# program.
need an explanation for this answer? contact us directly to get an explanation for this answer