Skip to content

Commit d648f6e

Browse files
author
Ram swaroop
committed
added content
1 parent 87ccefd commit d648f6e

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

_posts/2015-08-20-nested-classes.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,4 +641,39 @@ D. Compilation fails due to multiple errors
641641
E. Compilation fails due only to an error on line 4
642642
F. Compilation fails due only to an error on line 5
643643

644+
__Q7.__
645+
646+
{% highlight java linenos %}
647+
import java.util.*;
648+
649+
public class Pockets {
650+
public static void main(String[] args) {
651+
String[] sa = {"nickel", "button", "key", "lint"};
652+
Sorter s = new Sorter();
653+
for (String s2 : sa) System.out.print(s2 + " ");
654+
Arrays.sort(sa, s);
655+
System.out.println();
656+
for (String s2 : sa) System.out.print(s2 + " ");
657+
}
658+
659+
class Sorter implements Comparator<String> {
660+
public int compare(String a, String b) {
661+
return b.compareTo(a);
662+
}
663+
}
664+
}
665+
{% endhighlight %}
666+
667+
What is the output of the above program?
668+
669+
A. Compilation fails
670+
B. button key lint nickel
671+
nickel lint key button
672+
C. nickel button key lint
673+
button key lint nickel
674+
D. nickel button key lint
675+
nickel button key lint
676+
E. nickel button key lint
677+
nickel lint key button
678+
F. An exception is thrown at runtime
644679

0 commit comments

Comments
 (0)