File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes about primitive Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "about primitive" Watch "about primitive" New topic
Author

about primitive

Sundar Murthi
Ranch Hand

Joined: Mar 05, 2004
Posts: 209
Hi...
I am confused with the output of the following method output
any one explain to me



What will happen when you invoke the following method?


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


Ans given as b


what happens when b reaches maximum value?

thanks in advance.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Please try to search for recent posts on the same question. Thanks


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
K Patel
Greenhorn

Joined: Mar 29, 2004
Posts: 7
The print statements not in the while loop. And I byte will reset from 127 to -128 because the the byte will have a leading 1 now.
Sundar Murthi
Ranch Hand

Joined: Mar 05, 2004
Posts: 209
Thanks Gaunt and Patel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: about primitive