IS it Compulsory that a class name is same as file name in java?

Answers were Sorted based on User's Feedback



IS it Compulsory that a class name is same as file name in java?..

Answer / morais enrica rani

No its not necessary that

Is This Answer Correct ?    13 Yes 3 No

IS it Compulsory that a class name is same as file name in java?..

Answer / anuj sharma

No its not compulsory.
when you will compile the program then u will have the need
of java file that would be the naem of your .java file but
when u will run then after compilation .class will be
generate with same naem whatever you gave the class name in
java program. So no need to give the same name always.
its upto you coz its just a good practice purpose that we
usually give the same name of java file as our class name
with Iitial charater as Capital.

Is This Answer Correct ?    5 Yes 0 No

IS it Compulsory that a class name is same as file name in java?..

Answer / rasmitha

No.

Example:

class Test
{
Public static void main(String args[])
{
----------------
----------------------
}
Save the progrm as Ex1.java(any name we can give)

when we compile

>>javac Ex1.java

when we run the program to use class name having main method

>>java Test (it is must because execution starts with main)

Is This Answer Correct ?    4 Yes 0 No

IS it Compulsory that a class name is same as file name in java?..

Answer / linju

yes thhe main class name must be same as the class name in
java......

Is This Answer Correct ?    4 Yes 4 No

IS it Compulsory that a class name is same as file name in java?..

Answer / mohit jain

No its not compulsory for all program but some program are needed to same...

Is This Answer Correct ?    0 Yes 0 No

IS it Compulsory that a class name is same as file name in java?..

Answer / ajay gunjal

It is only recommended to use class name as a file name but it is not compulsory.
but if you have two or more classes with one is public and in that you write main() function then compiler create all class file but for searching of the entry point it is difficult and very tedious job.
so that's why if the class is public then use class name as a file name.

Is This Answer Correct ?    0 Yes 0 No

IS it Compulsory that a class name is same as file name in java?..

Answer / kaiwalya

YES

Is This Answer Correct ?    4 Yes 6 No

Post New Answer

More JSP Code Interview Questions

<% for(inti=0;i>3;++i;) sop(i); %> %

4 Answers   eClinicalWorks,


IS it Compulsory that a class name is same as file name in java?

7 Answers   Sun Microsystems, Wipro,


How to maintain session in Jsp?

4 Answers   IBM,


doors.txt;10;15

0 Answers  


give me the small script to add a global page through any domain?

1 Answers  






How to add flash or *.gif file in edit panel in java?

0 Answers  


Categories
  • PHP Code Interview Questions PHP Code (33)
  • JSP Code Interview Questions JSP Code (6)
  • ASP Code Interview Questions ASP Code (5)
  • CGI Perl Code Interview Questions CGI Perl Code (3)
  • JavaScript Code Interview Questions JavaScript Code (63)
  • VB Script Code Interview Questions VB Script Code (20)
  • Shell Script Code Interview Questions Shell Script Code (31)
  • Python Code Interview Questions Python Code (34)
  • WinRunner Code Interview Questions WinRunner Code (1)
  • HTML DHTML XHTML Code Interview Questions HTML DHTML XHTML Code (13)
  • XML Interview Questions XML (43)
  • Scripts_Markup Code AllOther Interview Questions Scripts_Markup Code AllOther (5)