Sunday, 18 November 2012

Some potential tripstraps for the SCJP exam.

  1. ·         Two top-level public classes cannot be in the same source file.
  2. ·         main() cannot call an instance (non-static) method.
  3. ·         Methods can have the same name as the constructor(s).
  4. ·         Watch for thread initiation with classes that don't have a run() method.
  5. ·         Local classes cannot access non-final variables.
  6. ·         Case statements must have values within permissible range.
  7. ·         Watch for Math class being an option for immutable classes.
  8. ·         instanceOf is not the same as instanceof.
  9. ·         Constructors can be private.
  10. ·         Assignment statements can be mistaken for a comparison; e.g., if(a=true)...
  11. ·         Watch for System.exit() in try-catch-finally blocks.
  12. ·         Watch for uninitialized variable references with no path of proper initialization.
  13. ·         Order of try-catch-finally blocks matters.
  14. ·         main() can be declared final.
  15. ·         0.0 == 0.0 is true.
  16. ·         A class without abstract methods can still be declared abstract.
  17. ·         RandomAccessFile descends from Object and implements DataInput and DataOutput.
  18. ·         Map does not implement Collection.
  19. ·         Dictionary is a class, not an interface.
  20. ·         Collection (singular) is an Interface, but Collections (plural) is a helper class.
  21. ·         Class declarations can come in any order (e.g., derived first, base next, etc.).
  22. ·         Forward references to variables gives a compiler error.
  23. ·         Multi-dimensional arrays can be "sparse" -- i.e., if you imagine the array as a matrix, every row need not have the same number of columns.
  24. ·         Arrays, whether local or class-level, are always initialized
  25. ·         Strings are initialized to null, not empty string.
  26. ·         An empty string is not the same as a null reference.
  27. ·         A declaration cannot be labelled.
  28. ·         continue must be in a loop (e.g., for, do, while). It cannot appear in case constructs.
  29. ·         Primitive array types can never be assigned to each other, even though the primitives themselves can be assigned. For example, ArrayofLongPrimitives = ArrayofIntegerPrimitives gives compiler error even though longvar = intvar is perfectly valid.
  30. ·         A constructor can throw any exception.
  31. ·         Initializer blocks are executed in the order of declaration.
  32. ·         Instance initializers are executed only if an object is constructed.
  33. ·         All comparisons involving NaN and a non-NaN always result in false.
  34. ·         Default type of a numeric literal with a decimal point is double.
  35. ·         int and long operations / and % can throw an ArithmeticException, while float and double / and % never will (even in case of division by zero).
  36. ·         == gives compiler error if the operands are cast-incompatible.
  37. ·         You can never cast objects of sibling classes (sharing the same parent).
  38. ·         equals() returns false if the object types are different. It does not raise a compiler error.
  39. ·         No inner class can have a static member.
  40. ·         File class has no methods to deal with the contents of the file.
  41. ·         InputStream and OutputStream are abstract classes, while DataInput and DataOutput are interfaces.
  42. import java.util.*;
    import statement doesn't import subpackage's(packages inside java.util package) classes, interfaces, Enums & annotations.
    It just simply import all these stuff inside the current package(java.util package)
  43. try-catch-finally
    whenever a exception occur in the try block it moved to the catch then further if there any exception occur in catch
    block it moved to the finally block..  
  44. dot (.) and pipe(|), these special symbols are really very special for java. whenever we use them we need to put  double back slash (\\) symbol to escape it. 

No comments:

Post a Comment