Page 1 of 1

About Question enthuware.ocajp.i.v7.2.855 :

Posted: Wed May 20, 2015 5:05 am
by subhamsdalmia
After changes,

public class P2{

public static void main(String[] args) throws Exception {
P2 t = new P2();
int i = t.getLoad();
double d = t.getLoad1();
System.out.println( i + d );
}

public int getLoad() {
return 1;
}

public double getLoad1(){
return 3.0;
}

}

Output:
4.0


Why will it convert to double?

Re: About Question enthuware.ocajp.i.v7.2.855 :

Posted: Wed May 20, 2015 5:14 am
by admin
1. Please use code tags so that the code is readable by others.
2. Why will what be converted to double?

Re: About Question enthuware.ocajp.i.v7.2.855 :

Posted: Wed May 20, 2015 5:33 am
by subhamsdalmia

Code: Select all

After changes,

public class P2{

public static void main(String[] args) throws Exception {
P2 t = new P2();
int i = t.getLoad();
double d = t.getLoad1();
System.out.println( i + d );
}

public int getLoad() {
return 1;
}

public double getLoad1(){
return 3.0;
}

}
Output:
4.0


Why will it convert to double?