What is the output of the following code.
public class Main{ public static void main(String[] args) { int a = 1 == 1 ? odd() : even(); } private static void odd() { System.out.println("Odd"); } private static void even() { System.out.println("Even"); } }
Type mismatch: cannot convert from void to int
public class Main{ public static void main(String[] args) { int aaaaaaa = 1 == 1 ? odd() : even(); }/* w w w . ja v a 2 s .com*/ private static void odd() { System.out.println("Odd"); } private static void even() { System.out.println("Even"); } }
We need a function which return int value to assign it to variable a.