0

Whenever i m declaring class A as public.. it is showing error..why?

class A { A(){} void d() { System.out.print("hi"); } } class Mcq33 extends A { public static void main(String args[]) { A r=new A(); r.d(); } void d() { System.out.print("bye"); } }

4th Apr 2017, 10:29 AM
Somnath Ghosh
Somnath Ghosh - avatar
2 odpowiedzi
+ 4
There must be only one public class in a Java file https://www.quora.com/Can-we-keep-more-than-one-class-in-a-single-java-file
4th Apr 2017, 11:40 AM
Heng Jun Xi
Heng Jun Xi - avatar
+ 3
if I am not mistaken sololearn allow it, maybe sololearn handle the code in different file
4th Apr 2017, 11:41 AM
Heng Jun Xi
Heng Jun Xi - avatar