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

Is java good for beginners?

579


What are peerless components?

616


Describe string intern() methodology

592


what is the difference between yielding and sleeping? : Java thread

523


Can an unreferenced object be referenced again?

756






What is private static class in java?

510


What is the purpose of skeleton and stub?

586


Explain the difference between a Thread and a Process.

556


What is a priority queue java?

523


What does g mean in regex?

559


Is singleton class thread safe?

532


Is space a character in java?

512


can java object be locked down for exclusive use by a given thread? Or what happens when a thread cannot acquire a lock on an object? : Java thread

530


What is nested interface?

518


what is meant by abstract class?

646