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
Can you override a final method?
What is static block?
What does it mean that a method or field is “static”?
What is exception propagation?
What is the difference between dom and sax parser in java?
What is an eror in java?
What is string builder?
How to create an immutable class?
Explain the differences between static and dynamic variables?
What is arraylist class in java?
What are java packages? What is the significance of packages?
Explain the difference between association, aggregation and inheritance relationships.
What checkbox method allows you to tell if a checkbox is checked?
What is the difference between procedural and object-oriented programs?
Is main an identifier?