public class BooleanExpression2 { public static void main(String[] args) { /*Question 2. Can the following conversions be allowed? What is this type of conversion called? Write a test program to verify your answer. boolean b = true; i = (int)b; int i = 1; boolean b = (boolean)i; */ //boolean cannot converte into i. boolean b = true; int i = (int)b; System.out.println(i); int i = 1; boolean b = (boolean)i; // this is incorrect answer. } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter