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> names = 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
Q84: Consider the following code snippet:
Int[][] arr =
{
{
Q85: What is the output of the following
Q86: What is true about the following code
Q86: Which statement is true about the code
Q87: Consider the following code snippet, where the
Q94: Which statement is true about the code
Q94: Which statement is true about the code
Q95: How many elements can be stored in
Q96: Which one of the following statements is
Q99: What is the output of the code
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