Why only one Class is public in one file? Explain in
details. Thanks in Advance.

Answer Posted / madan

public static void main(String args[])

this is command line args.. we need to declare public because, this is the main method, from any class, any package, we have to call, so it will be public.. same as class is also public...suppose, if u declare two class as public, it show error, we have to save a file somefile.java...

i think u understood based on above explanation..

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we override the overloaded method?

566


What are the 7 types of characters?

566


How can you make a class serializable in java?

569


Explain a situation where finally block will not be executed?

576


Explain the features of java?

597






What are the parts of methodology?

549


Program to Find the second largest element in an array.

591


Explain the difference between call by refrence and call by value?

563


Is space a string in java?

515


Why there are some null interface in JAVA? What does it mean? Give some null interface in JAVA?

618


What are the advantages of functions?

523


how we can create packages in java?

520


What is comparable and comparator interface? List their differences

581


How do you declare an empty string?

622


What is an empty list in java?

530