A.Instance variables are always initiated to defaults B.Local variables are always initiated to defaults C.Array Elements are always initiated to defaults D.Object references that are not initialized explicitly will have their value set to null always //I LIKED A , C AND D, BUT D IS WRONG, WHY ? WHAT ARE THOSE CASES WHEN OBJ REFERENCES CANT BE SET TO NULL BY DEFAULT ? Which are valid ? A.float f = 1.2; B.byte b = 255; C.long l = ( long )f; /* f is a valid float variable */ D.char c = 100; E. int i = (int) c1 + (int) c2; /* where c1 & c2 valid char primitives */ F.boolean bo = null; //I LIKED C AND D BUT ANSWER LIKES E AS WELL, IS THAT POSSIBLE, CAN CASTING BE DONE IN THIS FASHION , THANKS?!
Jini is correct about the first one. For the second one, that is exactly how you cast chars to ints so this is perfectly valid. In fact, the cast is redundant because whenever you add two primatives they are going to be converted to at least an int automatically. If one of the two is larger than an int, then they are automatically converted to the larger value, but it will always be at least an int. Bill