The static method atLongLast takes an array a of non-empty Strings and returns a String containing just the la?
-
The static method atLongLast takes an array a of non-empty Strings and returns a String containing just the last character of the longest String in a. (If there are more than one equally longest Strings in a, use the one with the smallest index in a. If a has no elements, return the empty String "".) For example: atLongLast( { "quite", "a", "short", "array" } ) has the value "e", and atLongLast( { "has", "one", "humongously", "long", "string" } ) has the value "y". Which of the following are suitable definitions for atLongLast? public static String atLongLast( String[] a ) { if ( a.length == 0 ) return ""; int maxIdx = 0; for ( int i = 1 ; i < a.length ; i++ ) { if ( a[ maxIdx ].length() < a[ i ].length() ) maxIdx = i; } return a[ maxIdx ].substring( a[ maxIdx ].length() - 1 ); } public static String atLongLast( String[] a ) { String s = ""; for ( int i = 0 ; i < a.length ; i++ ) { if ( s.length() < a[ i ].length() ) s = a[ i ]; } if ( s.equals( "" ) ) return ""; else return s.substring( s.length() - 1 ); } public static String atLongLast( String[] a ) { String s = ""; int maxIdx = 0; for ( int i = 1 ; i < a.length ; i++ ) { if ( a[ maxIdx ].length() < a[ i ].length() ) { s = a[ i ].substring( a[ i ].length() - 1 ); maxIdx = i; } } return s; } A I only B II only C I and II only D I and III only E I, II, and III I put D and I got it wrong, can someone please explain this to me and what the right answer is? Thank you!!
-
Answer:
sry cant get u
Emmy at Yahoo! Answers Visit the source
Related Q & A:
- How to mock static method call by constructor?Best solution by Stack Overflow
- What is the difference between a static method and class method in Python?Best solution by pythoncentral.io
- How to access a non static method in an abstract class's static method?Best solution by Stack Overflow
- How to get actual return type of a generic static method in Java?Best solution by stackoverflow.com
- How do I add to an array from a static method?Best solution by stackoverflow.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.