Q:
C#.Net find output programs (Inheritance) | 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 two classes ABC and XYZ. Here, we inherited class ABC into class XYZ.
Class ABC contains a no-argument constructor and a method FUN(), and class XYZ contains a no-argument constructor.
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 it calls the constructor of class ABC before calling the constructor of class XYZ because of inheritance. Then we called the FUN() method of ABC class.
Answer 2:
Output:
Explanation:
The above program will generate a syntax error because a protected member of a class can only be accessed in the child or derived class, here FUN() method is called in Main() method of Program, which is not possible due to protection level.
Answer 3:
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 no-argument constructor with a protected access modifier and a method FUN(), and class XYZ contains a no-argument constructor.
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 it calls the constructor of class ABC before calling the constructor of class XYZ because of inheritance. Here, constructor of ABC class is protected member; here it was called from child class XYZ. Then we called the FUN() method of ABC class.
Answer 4:
Output:
Explanation:
The above program will generate a syntax error because here we accessed the constructor of XYZ class from Program class, but here we declared constructor of XYZ as a protected member. But protected members can only be accessed in the same class on the derived class.
Answer 5:
Output:
Explanation:
The above program will generate two syntax errors because we cannot use an access modifier with destructors.
need an explanation for this answer? contact us directly to get an explanation for this answer