Question: What is the output of the following Java program? It is a single line of UPPER CASE LETTERS. (Try to figure these out without relying
What is the output of the following Java program? It is a single line of UPPER CASE LETTERS. (Try to figure these out without relying on running it - but it is challenging!)
interface FunFun { String run(String name); } public class Quiz { public static void main(String[] args) { FunFun f; f = n -> (n.charAt(0) + "" + n.charAt(n.length()-1)).toUpperCase(); String[] beatle = new String[4]; beatle[0] = "John"; beatle[1] = "Paul"; beatle[2] = "George"; beatle[3] = "Ringo"; for (int i = 0; i < beatle.length; i++) { beatle[i] = f.run(beatle[i]); } for (String b: beatle) System.out.print(b); System.out.println(); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
