Question: I'm having trouble with a bit of code: public static String compareLength(String a,String b) { if(a.length()==b.length()) { return Both are equal; } else if(a.length()>b.length()) {

I'm having trouble with a bit of code:

public static String compareLength(String a,String b) { if(a.length()==b.length()) { return "Both are equal"; } else if(a.length()>b.length()) { return a; } else { return b; } }

Although it runs fine, I keep getting the error isLeapYear(1992) incorrectly returns false.

This is the prompt for this section of code:

The method is a public static method called isLeapYear that returns a boolean. It takes in a parameter of type int. If the year is a leap year return true otherwise return false.

A year is a leap year if it is:

  • divisible by 4 and not divisible by 100
  • divisible by both 100 and by 400

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!