Consider the following code snippet: public static void main(String[] args)
{
ArrayList<String> names = new ArrayList<String>() ;
Names.add("John") ;
Names.add("Jerry") ;
Names.add("Janet") ;
ArrayList<String> names2 = reverse(names) ;
}
Public static ArrayList<String> reverse(ArrayList<String> names)
{
ArrayList<String> result = new ArrayList<String>() ;
For (int i = names.size() - 1; i >= 0; i--)
{
Result.add(names.get(i) ) ;
}
Return <String>result;
}
Which statement is true after the main method is executed?
A) names contains "Janet", "Jerry", "John" in this order
B) names contains "John", "Jerry", "Janet" in this order
C) reverse method has a bound error
D) Compilation error due to the return statement in reverse method
Correct Answer:
Verified
Q95: How many elements can be stored in
Q96: Which one of the following statements is
Q97: Which statement is true about the code
Q99: What is the output of the code
Q101: Assume the method createSomething has been defined
Q102: Assume the array of integers values has
Q103: What will be printed by the statements
Q104: What will be printed by the statements
Q105: Assume the array of integers values has
Q106: What should you check for when calculating
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents