Wednesday, 11 December 2013

JAVA BASIC LANGUAGE FUNDAMENTALS (1)


java language fundamentals

 1. Source file's elements (in order)

    Package declaration
    Import statements
    Class definitions

2. Importing packages does not recursively import sub-packages.

3. Sub-packages are really different packages, happen to live within an enclosing package. Classes in sub-packages cannot access classes in enclosing package with default access.

4. Comments can appear anywhere. Can't be nested. (No matter what type of comments).

5. At most one public class definition per file. This class name should match the file name. If there are more than one public class definitions , compiler will accept the class with the file's name and give an error at the line where the other class file is defined.

6. It's not required having a public class definition in a file. Strange, but true :-) . In this case , the file's name should be different from the names of classes and interfaces (not public obviously).

7. Even an empty file is a valid source file.

8. An identifier must begin with a letter, dollar sign ($) or underscore (_). Subsequently characters may be letters, $, _ or digits .

9. An identifier cannot have a name of a java keywords. Embedded keywords are OK, true, false and null are literals (not keywords), but they cannot be used as identifiers as well .

10. const and goto are reserved words, but not used .

11. Unicode characters can appears anywhere in the source code. The following code is valid:

    ch\u006r a='a';
    char \u0062='b';
    char c='\u0063';

12. All numeric data types are signed. char is the only unsigned integral type.

13. Object reference variables are initialized to nul.

14. Octal literals begin with zero. Hex literals begin with 0x or 0X .
15. Char literals are single quoted characters or unicode values (begin with\u).
16. A number is by default an int literals begin with 0x or 0X .
This entry was posted in .

1 comment: