1.)
long milli=24*60*60*1000;
long micro=24*60*60*1000*1000;
long result=micro/milli;
The result should be 1000
but it\'s not
You need to put an L
in there for long-conversion
long micro=24*60*60*1000*1000L
This feels jeopardy, having to guess the question as well as the answer. ;)
I think the second question should read
int i=0;
for(a=0;a<=Integer.MAX_VALUE;a++)
i++
This will go into an infinite loop because all possible values of a
are <= MAX_VALUE.
You can re-write this loop as
int a=0;
do {
i++
} while (a++ != Integer.MAX_VALUE);
i
will be Integer.MIN_VALUE as it overflows.
2)
public class test {
public static void main(String[] ar){
int i=0;
for(int a=0; a< Integer.MAX_VALUE;a++) {
i++;
}
System.out.println(i);
}
}
output:
2147483647