Sunday, April 27, 2008

Java Fundamentals - Points to remember

Java Fundamentals

Quick reference points

1. Keywords are the special reserved words in java that cannot be used as identifiers for classes, methods or variables.

2. const and goto are reserved but unused keyword in Java. If you use them in as identifiers, the compiler will throw an error.

3. include, overload, virtual, friend, unsigned, main are not keywords in java.

4. null , true and false are reserved values , they cannot be used as identifiers.

5. Java primitives are – byte(1 byte), short(2 bytes) , int (4 bytes), long(8 bytes), float (4 bytes) and double (8 bytes). All are signed values.

6. char is an integer type that can be assigned any value between 0 and 65535.

7. All integers are defined as int by default.

8. All floating point literals are double by default.

9. If we assign a floating point literal to a variable of type float, the complier will throw an exception. We should use ‘f’ or ‘F’ as a suffix to assign a floating point literal to a variable of type float.

10. A boolean literal can only have values – ‘true’ or ‘false’ (Case insensitive).

11. The characters are 16 bit (2 byte) unsigned integer under the hood. If we are assigning an integer value to a variable of type char, we should type cast it, else the complier will throw exception
o char a = 100 ; // legal
o char b = -100 ; // illegal
o char c = (char)-100; // legal
o char d = ‘a’ ; // legal
o char e = ‘\u1000’ ; // legal

12. Arrays are objects in java which stores multiple variables of same type.

13. Arrays are always Objects.

14. Array declaration is done by specifying the type of the variable being stored and the empty square brackets.

15. An Array of type A can store an Array of type B if B can satisfy ‘is A’ relationship of type A.

16. It is illegal to specify the size of an array during array declaration.

17. We should specify the size of an array during construction of an array.

18. Multi dimensional arrays are nothing but an array of arrays.

19. The dimensions in a multidimensional array can have different lengths.

No comments: