What is the file naming conventions to compile and run the programme(application) if there exists ,:icon_rolleyes:

  1. No class in a package;
  2. One class with default accessibility in a package;
  3. Many classes with default accessibilities in a package;
  4. Many classes with default accessibilities and one class with public accessibility in a package;
  5. Many classes with default accessibilities and many classes with public accessibilities in a package.

What will be if there is/are interface(s) in this connection:icon_question:

Also what will be the file naming methodology if the classes are of inner class category with different accessibilities, with different numbers 0, 1 or many

Why r u worried about access specifier of the classes ..?

when java provides a very effective naming space methodologies(using packages)..

Suppose, the main method is inside any default class whereas there is an another public class also; Now to compile, the file name will have to be- of the name of the public class. So to run the program, which should be selected as the file name; either the name of the public class which was selected to compile the file or the name of the default class which has the main method?
If, the default classes have the public or protected members, will the members be accessible outside of the package? Is this condition legal? If yes, where it is applied? Give some examples.

Provide reason why I should do your homework for you. What if you are trying to learn java? How will you learn java if you don't do your own homework? What if the information is readily available in the extensive documentation provided by Sun? Provide examples.

If you are new to Java I can understand your confusion. It really took me a while to get some grip of different protection levels. It is not anyone elses job to do your homework, but I will give you some links and explanation to start with and hopefully you will feel confident enough to try start coding. :)

Java is both a name-equivalence language and a name-equivalence environment. This means that things with the same name are seen as the same. If you have two classes with the same name but different implementations Java will not be able to tell them apart. In such a case, which class that will be used depends on the order in which the class files are encountered.

If you do not declare that your class belongs to a specific package it will automatically belong to a default unnamed package. Belonging to an unnamed package increases the possibility for classes with equal names to be mixed up. That is a good reason to start using packages already from the beginning. That is also a way to impress ones teacher. :)

Here you can read a bit about naming conventions:
http://www.oracle.com/technetwork/java/codeconventions-135099.html

Here you can read about classes and access controll of fields and methods.
http://download.oracle.com/javase/tutorial/java/javaOO/index.html

A top level class labeled as public is visible to all classes everywhere.
A top level class that has no label is visible only within its own package.

The same options applies to interfaces.

If an interface is labeled as public, then all its field and methods can be accessed as public.
If an interface is not labeled then all its field and methods can only be accessed inside the package the interface belongs to.

Fields and methods (in a class) that are labeled as private can only be accessed in their own class.
Fields and methods (in a class) that are not labeled at all can only be accessed in their own class and other classes inside the package the class belongs to.
Fields and methods (in a class) that are labeled as protected can only be accessed in their own class, other classes inside the package the class belongs to and subclasses to their own class inside other packages.
Fields and methods (in a class) that are labeled as public can be accessed from all classes everywhere.

Good luck :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.