Wednesday 11 March 2009

Some random things about java

Those who know java well,this post is not for you. These things are in your blood. I’m sure you’ll get bored while reading it again.

1)Java version 1.2 onwards come in 3 flavours : Micro edition, J2SE : Standard Edition, J2EE : Enterprise Edition

2)To define a global method in Java or in any OOPL, we make it public and static. Whereas to define a global constant variable we make it public, static and final.

3)Dog d = new Dog();
Left part creates reference for the object of class Dog.
Right part creates the actual object. And assignment operator does linking between them. In java, there are all references to the objects of class.Everything is a reference, no actual variable.

4)Getters and setters are to protect private variables from getting accessed by unwanted entities and also to perform validation on the values set for variables when required. When I had started learning OOP, I had felt what timepass we do when we use get and set methods!! But there is always a reason . for everything. We just need to find it.

5)The difference between instance variables and local variables : Instance variables are declared inside class definition whereas local variables are defined inside a method definition. Instance variables need not be initialized before using them as they get assigned with default values. (number variables and char have 0, booleans have false and object references have null default values.) Whereas. Local variable must be initialized before their use.

6)Extreme Programming : Developing in Iterations. Agile Methodology. Galileo. All are similar. Amdocs is despensing Galileo technique.
For more information on it : Click or wiki on it.

7)import statements are not like include statements. They don’t put the while class definition in the file where we write import statement. They just allow us not to write the whole class name ( like java.util.ArrayList)

8) How javax came into picture? Why this x?
-> This is a nice story. I don’t want to write it here. If I start writing, I won’t be able to finish writing this post today. If I get some link I will post it here.

9)Why interfaces in Java? Why not multiple inheritance? Both answers are complimentary to each other. To avoid complexities java doesn’t support multiple inheritance and hence introduces interfaces.

10)When to use interface and when to inherit class? When the entity is something e.g.Dog is an animal so it extends class animal. But a pet dog does some functions. So it will implement interface – Pet. When you are something, that's because you inherit it. But when you do something that’s because you implement something.

No comments: