Why does java not allow multiple public classes in a java file ?
Answer Posted / sushila sonare
suppose in java file so many classes, interfaces, abstract
classes and enumerations are there. we can keep only one of
them as a public because its shown a container and this
container we are keeping all things in our java file.
if we kept public for more then one class then all are that
classes qualified as a container or we are called it
execution unit. again compiler get confuse which container
classes has to kept. So avoiding this confusion multiple
public classes are not allowed in java.
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the purpose of garbage collection in java, and when is it used?
What is the size of int in 64-bit jvm?
What is executor memory?
Which way a developer should use for creating thread, i.e. Sub classing thread or implementing runnable.
What is difference between fileinputstream and filereader in java?
What is valid keyword in java?
Why null value is used in string?
Define class?
What are the kinds of polymorphism?
What are user defined exceptions?
Say you want to store the information about a number of pets in an array. Typical information that you could store for each pet (where relevant) would be • Breed of animal • Animal's name • Its birth date • Its sex • Whether it has been sterilised or not • When it is due for its next inoculation • When it last had its wings clipped For each type of pet (eg. dog, cat or bird) you would typically define a class to hold the relevant data. Note: You do not need to implement these classes. Just answer the following questions. 3.1.1 What would be the advantage of creating a superclass (eg. Pet) and declaring an array of Pet objects over simply using an array of Objects, storing each of the instances of the different pet classes (eg. Dog, Cat or Bird) in it? 3.1.2 Would you define Pet as a class or as an interface? Why? (2) (2)
Can we convert stringbuffer to string?
What is exception handling in java?
What is the difference between sop and work instruction?
How to make a class or a bean serializable?