+ 5

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. https://code.sololearn.com/c6h4wrAOok3j/?ref=app

4th Dec 2021, 2:36 PM
ShadowCipher
ShadowCipher - avatar
4 Answers
+ 3
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.
4th Dec 2021, 3:19 PM
Ipang
+ 5
Ooooh okay thanks Ipang let me try
4th Dec 2021, 3:20 PM
ShadowCipher
ShadowCipher - avatar
4th Dec 2021, 3:33 PM
ShadowCipher
ShadowCipher - avatar
+ 2
Good job Kapama, Joshua 👍
4th Dec 2021, 3:35 PM
Ipang