1. It will print 2014 2. public class Question2 { public static int findMax(double[] a) { int pos = -1; double max = 0; for (int i = 0; i < a.length; i++) { if (a[i] > max) { max = a[i]; pos = i; } } return pos; } public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) { a[i] = Double.parseDouble(args[i]); } int pos = findMax(a); if (pos < 0) System.out.println("No numbers found"); else System.out.println("The biggest number "+a[pos]+" is found at position "+pos+"."); } } 3. public class Polynomial { private double[] a; public Polynomial(double[] a) { this.a = a; } public double eval(double x) { double exp = 1; double sum = 0; for (int i = 0; i < a.length; i++) { sum += a[i]*exp; exp *= x; } return sum; } public String toString() { String s = ""; for (int i = 0; i < a.length; i++) { if (i == 0) s += a[i]; else if (i == 1) s += " + "+a[i]+"*x"; else s += " + "+a[i]+"*x^"+i; } return s; } } 4. public static String replace(String s, String s1, String s2) { String res = ""; int i = 0; while (i < s.length() - s1.length() + 1) { boolean match = true; for (int j = 0; j < s1.length(); j++) { if (s.charAt(i+j) != s1.charAt(j)) { match = false; break; } } if (match) { res += s2; i += s1.length(); } else { res += s.charAt(i); i += 1; } } while (i < s.length()) { res += s.charAt(i); i += 1; } return res; } 5. public static List merge(List l1, List l2) { int len = Math.min(l1.size(), l2.size()); List res = new ArrayList(); int i = 0; while (i < len) { res.add(l1.get(i)); res.add(l2.get(i)); i++; } while (i < l1.size()) { res.add(l1.get(i)); i++; } while (i < l2.size()) { res.add(l2.get(i)); i++; } return res; }