Hi preeti ,
1. Nop.only the output will be 3 . Thats all. The value u r giving in the method parameter must be cast-compatiable with method parameter type.Only in method three all r converted to double.(wideneing )
2.
Some little bit change to ur code.
class A
{
int i=30;
A()
{
print();
}
void print()
{System.out.println(i);}
void method1(){
System.out.println("Parent");
}
}
public class
test extends A
{
int i=Math.round(3.5f);
void print()
{
//line 1
System.out.println(i);
}
void method2(){
System.out.println("Child");
}
public static void main(
String args[])
{
test a=new test();
a.method1();
a.print();
}
}
now .the o/p will be 0 parent 4 .
Yes..u r right that static and instance expression called b4 constructor BUT they at first intialized or get the default values.
Not the exact value they assigned. As u calling 4rm the constructor they r showing there default values.
Hope that helps.
BUt ...my q. 2 others,if I add some code like 'super.print()' ..then the o/p will be 30 0 parent 30 4 . But how ??
Thanks in Advance.
<marquee>
Ratul Banerjee </marquee>