What will happen when you invoke the following method?
void infiniteLoop ( ) {
byte b = 1 ;
while ( ++b > 0 ) ;
System . out . println ( " Welcome to
Java " ) ;
}
Options :
a . The loop never ends ( infinite loop ) .
b . Prints " Welcome to Java " to the console
c . Compilation error at line 5. ++ operator should not be used for byte type variables.
d . Prints nothing but terminates after some time
Answer : b
Can anyone explain me the reason...
I guess while(++b>0); is an infinite loop.
thanks in advance..
rajani.