0

is it compulsory to have class name same as source file name????

I wrote a program with first as class name and save run as source file name but it runs successfully why???. it doesn't gives any error

5th Sep 2016, 12:06 PM
Ankit Gupta
Ankit Gupta - avatar
6 Antworten
+ 1
Yes. My program on eclipse didn't work when class and saved file name was different.
5th Sep 2016, 12:30 PM
nayan
nayan - avatar
+ 1
If you define the class name as 'public', then the name of the file and the class will HAVE to be the same, else, no.
6th Sep 2016, 12:19 PM
Akshay Sinha
Akshay Sinha - avatar
+ 1
thanks
6th Sep 2016, 12:32 PM
Ankit Gupta
Ankit Gupta - avatar
0
no
5th Sep 2016, 2:13 PM
gurkirt Singh
gurkirt Singh - avatar
- 1
not necessary. while compiling compile with the class name and while running the program run it with file name with which u saved the file
5th Sep 2016, 12:17 PM
Sonu Mishra
Sonu Mishra - avatar
- 1
its not mandatory to have class name and file name same.
5th Sep 2016, 12:18 PM
Sonu Mishra
Sonu Mishra - avatar