Consider the following question and the answers
pattern [question from the marcus green exam for
scjp 1.4]
-----------------------------------------------------
What will happen when you attempt to compile and run the following code?
class Base{
private Integer iwNum;
public Base(Integer iw){
iwNum=iw;
System.out.println(iwNum);
}
}
public class Moss{
public static void main(
String argv[]){
Moss m = new Moss();
m.blossom();
}
public void blossom(){
float f = 10;
knavesmire(f);
}
public void knavesmire(double d){
int i = (int)d;
Integer iw = new Integer(i);
Base b= new Base(iw);
}
}
1) Compile error, double cannot be cast to int
2) Compile error, a value assigned to a float must have a decimal component
3) Compilation and output of 10
4) Compilation and output of 10.0
-----------------------------------------------------
Please answer to the following
a) Compile error ---" double cannot be cast to int "
Compile error--" a value assigned to a float must have a decimal component"
Is the "reason for the compiler error" explicitly mentioned
in the real exam???
PLEASE HELP ME OUT WITH THIS???