public class VecOrder{
public static void main(String argv[]){
new VecOrder();
}
VecOrder(){
Vector
child.add("harry");
child.add("molly");
child.add("steven");
child.add("helen");
Collections.sort(child);
for(String element : child){
System.out.print(element);
}
}
}
Answers:...........
1 :Compilation error, problem with creation of instance of Vector class
2 :Compilation but runtime error, the Collections.sort method can only sort objects of type List
3:Compilation error, the for loop structure needs to cast each element of the Vector array to a String
4:Compilation and output of harryhelenmollysteven
No comments:
Post a Comment