Which line/lines will compilation error occur in?

public class Test {
    public static void main(String[] args) {
        char c = (char) 1; // 1
        boolean boo = (boolean) 1; // 2
        byte b = (byte) true;    // 3
    }
}
Explanation
1 initially is of type int that can be cast to char
int cannot be cast to boolean
boolean cannot be cast to byte
Java
Java Quiz
Start Quiz

or Read more about Java Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback