Package :

video

Coding Conventions in Java :

video

Notes :

  • Always give meaningful name to class, variables, methods and so on.
  • Use all caps for naming final variables. If it contains two words then separate them using underscore( _ ). Eg: PI, MAX_SIZE
  • Packages name should be always small letters as in linux folders names are case sensitive but in windows its not.
  • Pascal convention should be used for naming class & interface. i.e First letter of every word should be capital.
  • A noun should be used for naming a class as it is used for representing a single real world object.
  • An adjective should be used for naming an interface. Eg: Doable, Jumpable, Runnable etc.
  • Camel convention should be used for naming data members, variables, references and method name. If they contain only one word then we can name them using small letters.
  • A method name should indicate a verb, an action, as it’s a behavior.

Packages & Conventions in Java Interview Questions :

  1. Do I need to import classes or interface present in java.lang package in my program ?
  2. Can I import same package or class twice ? Will the JVM load package twice at runtime ?
  3. What is static import ?