What are the Potential Trips/Traps in SCJP exam

  1. Two public classes in the same file.
  2. Main method calling a non-static method.
  3. Methods with the same name as the constructor(s).
  4. Thread initiation with classes that dont have a run() method.
  5. Local inner classes trying to access non-final vars.
  6. Case statements with values out of permissible range.
  7. Math class being an option for immutable classes !!
  8. instanceOf is not same as instanceof
  9. Private constructors
  10. An assignment statement which looks like a comparison if ( a=true)...
  11. System.exit() in try-catch-finally blocks.
  12. 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 doesnot implement Collection.
  19. Dictionary is a class, not an interface.
  20. Collection is an Interface where as Collections is a helper class.
  21. Class declarations can come in any order ( derived first, base next etc. ).
  22. Forward references to variables gives compiler error.
  23. Multi dimensional arrays can be sparce ie., 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 string.
  27. A declaration cannot be labelled.
  28. continue must be in a loop( for, do , while ). It cannot appear in case constructs.
  29. Primitive array types can never be assigned to each other, eventhough the primitives themselves can be assigned. ie., ArrayofLongPrimitives = ArrayofIntegerPrimitives gives compiler error eventhough longvar = intvar is perfectly valid.
  30. A constructor can throw any exception.
  31. Initilializer blocks are executed in the order of declaration.
  32. Instance initializer(s) gets executed ONLY IF the objects are constructed.
  33. All comparisons involving NaN and a non-Nan would always result false.
  34. Default type of a numeric literal with a decimal point is double.
  35. integer (and long ) operations / and % can throw ArithmeticException while float / and % will never, 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 ), even with an explicit cast.
  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.

See also

Do you have a Java Problem?
Ask It in The Java Forum

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.