// Java program to check Leap-year // by taking input from user // Importing Classes/Files import java.io.*; // Importing Scanner Class import java.util.Scanner; // Class to check leap-year or not public class GFG { // Driver code public static void main(String[] args) { // Considering any random year int year; // Taking input from user using Scanner Class // scn is an object made of Scanner Class Scanner scn = new Scanner(System.in); year = scn.nextInt(); // 1st condition check- It is century leap year // 2nd condition check- It is leap year and not // century year if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))) { // Both conditions true- Print leap year System.out.println(year + " : Leap Year"); } else { // Any condition fails- Print Non-leap year System.out.println(year + " : Non - Leap Year"); } } }public static boolean isLeapYear(int year) { if (year % 4 != 0) { return false; } else if (year % 400 == 0) { return true; } else if (year % 100 == 0) { return false; } else { return true; } }(year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)) public static boolean isLeapYear(int year) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, year); return cal.getActualMaximum(Calendar.DAY_OF_YEAR) > 365; } public static boolean isLeapYear(int year) { if (year % 4 != 0) { return false; } else if (year % 100 != 0) { return true; } else if (year % 400 != 0) { return false; } else { return true; } } boolean isLeap = new GregorianCalendar().isLeapYear(2020); //returns true public class LeapYear { // Method to check leap year public static void checkLeapYear(int year) { if (year % 400 == 0) { System.out.println(year + " is a leap year."); } else if (year % 100 == 0) { System.out.println(year + " is not a leap year."); } else if (year % 4 == 0) { System.out.println(year + " is a leap year."); } else { System.out.println(year + " is not a leap year."); } } public static void main(String[] args) { // Examples checkLeapYear(1998); checkLeapYear(2000); } } Output: 1998 is not a leap year. 2000 is a leap year.import java.util.Scanner;public class Main{public static void main(String[] args){int year;System.out.println("Enter the year");Scanner sc = new Scanner(System.in);year = sc.nextInt();if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0))System.out.println("it is a leap year");elseSystem.out.println("it is not a leap year");}}