The code is to check whether a number is even or odd using the last bit is 1 or 0. if last bit is 1 it will go in if and print odd
import java.util.Scanner;
public class Even_or_odd {
public void Check_even_or_odd(int a) {
if(a&1)//error:Type mismatch: cannot convert from int to boolean
System.out.println("odd");
else
System.out.println("even");
}
public static void main(String[] args) {
System.out.println("enter a number to check even or odd");
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
scan.close();
Even_or_odd e=new Even_or_odd();
e.Check_even_or_odd(a);
}
}