What will be the output

I have a confusion in java....primitive variables are instantiated during decleration.....? ... if yes than .....what will be out put of following pseudocode

class A {

// variable decleration

final int i;

}

public static void main( String []a){

System.out.println( "value of i is "+ new A().i );

}

dont u thgink it should give run time error...

[401 byte] By [mayaaaa] at [2007-11-27 11:24:44]
# 1

Numerical instance variables are initialized to 0.

-Kayaman-a at 2007-7-29 16:00:06 > top of Java-index,Java Essentials,Java Programming...
# 2

it should print 0, as in class scope all primitives are initialised with 0 (or equivalent value)

in other method or block scope though, primitives are not initialised standardly

public void testMethod() {

int i;

System.out.println("value of i: " + i);

}

shouldnt even compile (message: "Variable 'i' might not have been initialized")

Vectorizeda at 2007-7-29 16:00:06 > top of Java-index,Java Essentials,Java Programming...
# 3

but it is final.....will that have any efftect on it

mayaaaa at 2007-7-29 16:00:06 > top of Java-index,Java Essentials,Java Programming...
# 4

No.

-Kayaman-a at 2007-7-29 16:00:06 > top of Java-index,Java Essentials,Java Programming...
# 5

> but it is final.....will that have any efftect on it

No. The answers given don't change with the final keyword.

~

yawmarka at 2007-7-29 16:00:06 > top of Java-index,Java Essentials,Java Programming...
# 6

ok ...thanks yaar

mayaaaa at 2007-7-29 16:00:06 > top of Java-index,Java Essentials,Java Programming...
# 7

> ok ...thanks yaar

It's not Talk Like A Pirate Day already, is it? I thought that was September 19...

~

yawmarka at 2007-7-29 16:00:06 > top of Java-index,Java Essentials,Java Programming...
# 8

> > ok ...thanks yaar

>

> It's not Talk Like A Pirate Day already, is

> it? I thought that was September 19...

>

> ~

Surely you don't have to wait for pirate day to talk like a pirate..... its a right which should be exploited at everytime chance matey.

Avast!!

ita6cgra at 2007-7-29 16:00:06 > top of Java-index,Java Essentials,Java Programming...
# 9

But why is the rum gone?

~

yawmarka at 2007-7-29 16:00:06 > top of Java-index,Java Essentials,Java Programming...