What Is The Output Of The Following Java Codep Pre Langjava #490
What is the output of the following Java code?</p> <pre><code class="language-java"> class LeapYear { static int flag=0; public static void main(String arg[]) { System.out.print(leap(2004)); System.out.print(leap(2000)); System.out.print(leap(1900)); } static int leap(int year) { if(year!=0) { if(year%400==0) { flag=1; } else if(year%100==0) { flag=0; } else if(year%4==0) { flag=1; } else { flag=0; } } return flag; } }</code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs111 OOP Object Oriented Programming Java. It can also be found in gs gs111 Class Components (Using Java) - Member Functions - Quiz No.2.