Originally posted by Vejaykrishna:
HI,
In K&B book p:112 there is an example program which explains reference variable casting. can anybody explain me line: 3 and 4.
1. class CastTest2{
2. public static void main(String [] ar){
3. Animal[] a={new Animal(), new Dog(), new Animal()};
4. for(Animal animal : a){
5. animal.makeNoise();
6. if(animal instanceof Dog){
7. animal.playDead();
8. }}}}
If a unchecked exception is thrown in try block, that will be printed after executing the finally block.
Originally posted by Naren Chivukula:
Hi,
Not always this happen. If a unchecked exception is thrown in try block, that will be printed after executing the finally block.
Only once A's constructor is completed will the value of A's instance variable i be initialized to 7.