Little help please | Sololearn: Learn to code for FREE!


Little help please

Question is --> Class Beta inherit from class Alpha. The constructor of class alpha displays "a". While the class beta Constructor displays "b". What is the output on the screen when the code below is run: Alpha a = new Beta(); //the answer has to be 'ab' according to Sl's lesson qn. Below is my attempt i didn't get it right.

12/4/2021 2:36:20 PM

Kapama, Joshua

4 Answers

New Answer


Please read the task carefully, it says (quoted) "The constructor of class Alpha displays 'a'. While the class Beta constructor displays 'b' ..." In your code, neither Alpha or Beta class had a constructor defined. Instead you have created a void Display() method which was not required by the task. Just create a constructor for each class, and print 'a' or 'b' in respective class constructor, accordingly. No need for Display() method.


Ooooh okay thanks Ipang let me try


Thanks again Ipang solved it


Good job Kapama, Joshua 👍