Thursday, April 19, 2007

Java - making me crazy

Since a long time, I’m planning to appear for SCJP exam. Finally I have determined to appear for it soon. Though I like java a lot, but there are some things which make me think that it is a funny language! It’s driving me crazy. Don’t you believe me? See this:

  1. Any local variable but be initialized before use, but if the local variable is an array the compiler won’t complain. Only declaring and constructing the array will do.
  2. Multiple inheritance is not allowed in java but interface classes can extend more than one interface classes. They are VIPs :)
  3. Interface variables are implicitly but static and final but compiler will be angry if we make the interface methods as static or final.
  4. Everyone who has learnt java knows when we’ll try to divide an integer by 0, it will result in an ArithmeticException but dividing a floating point number by a zero will not result in an ArithmeticException. Isn’t it strange!
  5. We can do & and operations on integers as well as Booleans but we can do && and only on Boolean operands.
  6. We can have multiple initialization and iteration statements in for loop but there can be only one test condition.Why so? They could have used multiple tests also
    Constructors should not have a return type but its legal to have a method with the same name as that of class with a return type. SO what do I do if I see a method with a return type – is it an errored constructor or a legal method?
  7. Default constructor is always a non-arg constructor but you won’t get it if you have typed in a constructor with arguments. Why this injustice to the programmer?

    These are just a few things that I wrote. I’m still in the mid of my course. If some big java fan happens to read this, please don’t beat me for writing this.

2 comments:

Vaibhav Choudhary said...

Nice to see a java blog in between the daily blog. This is the class(not object-class) of java. By the way if you want any material for SCJP, you can ask me.

Khushboo said...

Thanks Vaibhav! Yes..do give me some tips for the SCJP exam :) My exam is on saturday..