Thursday, August 2, 2007

SCJP Hand outs Part-1

  1. The floating-point numbers did not throw divide by zero ArithmeticException. They will give a result that is Not A Number NAN.
  2. The case argument must be either an int literal , or an int-compatible variable which is a constant (i.e static or final)
  3. Assume byte a=3; byte b=2; byte c= a+b; à Compile time error because the addition operator will wide the byte to int before addition and result should be stored in int variable.
  4. An abstract class can have a constructor.
  5. It is legal to access a static method using an instance of the class. But it is preferred way to use the class name to access.
  6. Methods can be overridden Attributes/member variables can not.
  7. If a try/catch block calls System.exit() then finally block will not execute.
  8. A member variable can not be native.
  9. Constructors are not inherited.
  10. You can not automatically/implicitly convert a char to short. There is same bit depth but since char are unsigned they might have higher positive value than a short can accept.
  11. Arithmetic Exception is not a checked exception.
  12. An interface can extend multiple interfaces however a class can extend only one class.
  13. A member variable can not be declared synchronized.
  14. Math.round(-3.22) = -3
  15. You can not make a final abstract class.
  16. A constructor of a class can not be declared static.
  17. Inner classes can not be defined in a class outside of its methods like where declaring member variables.
  18. A class can not be declared transient.
  19. A method can not be declared transient.
  20. static methods of a class can not be accessed using this.MethodName().
  21. Only variables can be declared as volatile.
  22. A floating point literal (like 3.45) in java will be treated as double unless you specify an f at the end like (3.45f).
  23. A top level class can not be marked as private.
  24. An overloaded method can change the return type, but return type alone is not enough—it also must change the argument list.
  25. If there is a return statement in try/catch block then finally block will also be executed.
  26. int iArray[5] = new int[] {1,2,3,4,5}; will not compile but int iArray[] = new int[] {1,2,3,4,5}; will compile.
  27. An anonymous inner class can not have a constructor.
  28. Result of System.out.println(Math.sqrt(-4)); is equal to NAN.
  29. A top level class can not be marked as protected.
  30. cast is not a keyword in JAVA.

No comments: