+ 3

Hybrid inheritance in java

Is this code for hybrid inheritance in java valid. I am getting the desired output. OUTPUT: class C class D class D (This program will not run properly on sololearn) https://code.sololearn.com/cwIu3sWs251u/?ref=app

18th Jun 2018, 10:07 PM
harshit
harshit - avatar
5 Answers
+ 4
You can call the class anything. SoloLearn expects to find main in the first class it sees so putting class C after class D would let your code run here. https://code.sololearn.com/ceJ2g7J23qWM
18th Jun 2018, 11:18 PM
John Wells
John Wells - avatar
+ 2
thanks
18th Jun 2018, 11:20 PM
harshit
harshit - avatar
+ 1
seems correct on first glance. why did you put the main function in class D? just put it in an appropriatly named class and the code should run on sololearn
18th Jun 2018, 10:21 PM
Max
Max - avatar
+ 1
appropriately named class means? because on my compiler this code works.
18th Jun 2018, 10:32 PM
harshit
harshit - avatar
+ 1
when you create a code in sololearn the class which contains the main methods is called Program and i assume the file is also called Program. since you can‘t change the filename on their server i think your main method has to be in a class called Program, and i dont think this class Program should implement from A and B but rather use D. its just one of the quirks of the sololearn enviroment
18th Jun 2018, 10:36 PM
Max
Max - avatar