Java Puzzle
Question:
In lines:
Fixed version :
class Puzzle {
public static void main(String[] args) {
System.out.print(12345 + 5432l);
System.out.print(" ");
System.out.print(01234 + 43210);
}
}
Output :
17777 43878
In lines:
System.out.print(12345 + 5432l);
5432l ---- Its last character is L -- means longSystem.out.print(01234 + 43210);
01234 ---- Here starting digit is 0 which means octal Fixed version :
class
Puzzle
{ public static void main(String[] args) { System.out.print(12345 + 5432L); // make the last character L System.out.print(" "); System.out.print(1234 + 43210); // drop the 0 } } Output : 66666 44444
Comments
Post a Comment