Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Explain class A{}
class B{}
class C{}
all the three classes are saved in a single file name, what
the name should i provide to the file ,in what file name
should i run the program? Ple Explain

Answers were Sorted based on User's Feedback



Explain class A{} class B{} class C{} all the three classes are saved in a single file name, what..

Answer / sarabjit singh

when a code is to wriiten in a single file, no matter how
many number of classes being used, the de-facto standard
for naming the file is <ClassName>.java,
where <ClassName> is the name of the class containing the
main function().
Hence in our case, if class A is having the main() method,
then the file name would be A.java.

Is This Answer Correct ?    14 Yes 2 No

Explain class A{} class B{} class C{} all the three classes are saved in a single file name, what..

Answer / santhosh

where the main() is there
that name give to as file name
that is public also

Is This Answer Correct ?    9 Yes 5 No

Explain class A{} class B{} class C{} all the three classes are saved in a single file name, what..

Answer / mohammad faisal

The most common answer is: it would be the class name
having the main() method.

If you are using multiple classes in a single file than it
doesn't matter how much the number of classes.
But there is a problem for begienners that by what name
should they save the file.

There is something interesting to java:
You can save the program by any name. i.e.,
Let your program is:
class a
{
}
class b
{
}
class c
{
public static void main(String args[])
{
}
}

Now save the file as Amazing_Example.java

Compile the file as:
c:\>javac Amazing_Example.java
c:\>
This compilation is successfull.
Now you can run the program using the name of class having
the main() method. As in our example class c has the main()
method.
i.e.,
c:\>java c
c:\>//Here will be the output of your code.

Is This Answer Correct ?    4 Yes 0 No

Explain class A{} class B{} class C{} all the three classes are saved in a single file name, what..

Answer / vijay

if i am taking in context of this question is interview
question to check our command on java knowledge
then......all the above are wrong except @Mohammad Faisal
Answer...all other answer only for java begienners for
avoiding confusion.

otherwise we can save our program with any name and after
compilation all the classes create its own .class file and
we run our program with that .class file which having the
public static main() method.

Is This Answer Correct ?    2 Yes 0 No

Explain class A{} class B{} class C{} all the three classes are saved in a single file name, what..

Answer / anandhi

class a
{
}
class b extends a
{
}
class c
{
public static void main(String arg[])
{
b b1=new b();
....
}
}
so file name c...

Is This Answer Correct ?    3 Yes 2 No

Explain class A{} class B{} class C{} all the three classes are saved in a single file name, what..

Answer / cool_duzz

The name of the file should be the same as the class having
public access modifier.. otherwise u can put it the way u
like. 3 .class files will be generated by compiler.

Is This Answer Correct ?    5 Yes 5 No

Explain class A{} class B{} class C{} all the three classes are saved in a single file name, what..

Answer / ravikiran

any name because nothing marked public

Is This Answer Correct ?    2 Yes 6 No

Explain class A{} class B{} class C{} all the three classes are saved in a single file name, what..

Answer / dipil t t

class A{},class B{}and class C{} Shold be public then we
can select main class name is the file name.

Is This Answer Correct ?    1 Yes 5 No

Explain class A{} class B{} class C{} all the three classes are saved in a single file name, what..

Answer / aburar yaseen

we have to have the file name of the class having main
function. if all the three classes are having the main
method we can have any one of the class name as file name.

Is This Answer Correct ?    2 Yes 7 No

Post New Answer

More Core Java Interview Questions

Describe the syntax of multiple inheritance? When do we use such an inheritance?

0 Answers   Fidelity,


What are local variables?

0 Answers  


Which class should you use to obtain design information about an object in java programming?

0 Answers  


Is null a string or object in java?

0 Answers  


byte a=5; byte b=5; byte c=a+b; System.out.println(c); whats the o/p?

7 Answers   NIIT, Wipro,


What is meant by JVM ?

6 Answers  


what is dynamic method dispatch ?

27 Answers   Fidelity, MUET, SDSF,


Explain scope or life time of local variables in java?

0 Answers  


What is the vector class in java programming?

0 Answers  


What is sizeof in java?

0 Answers  


List types of storage classes in java?

0 Answers   Cyient,


What are the types of arrays in java?

0 Answers  


Categories