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

Answer Posted / ganesh slv

You can create one or more classes in single file. Only one
class may be declared as public. This is your Optional.

If you declared a class as public, your file name should be
the save of your class name.

Public class can be accessible from other applications.
Example, your applet code can be run in a web browser. This
public class may execute other classes in the same file.

If you declared two classes as public, your file name will
be what?

Note the Example :

class First {
// Some codes here
}

public class Second {
// some codes here
// In core, your main method should be here.
// You have to save the file as Second.
}

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is charat java?

546


What method is used to specify a container's layout in java programming?

548


How to display all the prime numbers between 1 and 100

509


Is call by reference possible in java?

540


What is the purpose of format function?

630






What is r in java?

595


What is variable explain?

530


What are keywords in programming?

570


What is the main advantage of passing argument by reference?

507


What is the list interface?

612


How do you call a reference in java?

523


How to compare two strings in java program?

678


Why java is platform independent? Explain.

603


Explain which of the following methods releases the lock when yield(), join(),sleep(),wait(),notify(), notifyall() methods are executed?

617


What is the difference between declaration and definition in java?

519