This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Anothe one from Whizlabs software. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Anothe one from Whizlabs software." Watch "Anothe one from Whizlabs software." New topic
Author

Anothe one from Whizlabs software.

Latha Kota
Ranch Hand

Joined: Mar 13, 2003
Posts: 35
I found this question from Whizlabs software. I thought that the output would be 2.6 since it is assigned to a double variable. But the output is 2.0. Below is the code:
int a = 8;
int b = 3;
double f = a++/b--;
System.out.println(f);
The answer is 2.0 but I was expecting 2.6.
Thanks
Latha
Bojan Knezovic
Ranch Hand

Joined: Nov 20, 2003
Posts: 90

Operators are of type int, so the result will be as well. Later on it will be automatically widened to conform to the size of float.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Anothe one from Whizlabs software.