Which of the following declarations are correct? (Choose TWO)
1.boolean b =TRUE;
3
4
Consider the following code and select the correct output:
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class Lists
{
public static void main(String[] args)
{
List list=new ArrayList();
list.add("1"); list.add("2");
list.add(1, "3");
List list2=new LinkedList(list);
list.addAll(list2); list2 =list.subList(2,5);
list 2.clear(); System.out.println(list);
}
}[1,3,2]
[1,3,3,2]
[1,3,2,1,3,2]
[3,1,2]
1
Which statements, when inserted at (1), will not result in compile-time errors?
public class ThisUsage
{
int planets;
static int suns;
public void gaze()
{
int I;
// (1) INSERT STATEMENT HERE } } i =this.planets; i = this.suns; this = newThisUsage(); this.suns =planets;Given:
import java.util.*;
public class LetterASort
{
public static void main(String[] args)
{
ArrayList strings = new ArrayList();
strings.add("aAaA");
strings.add("AaA");
strings.add("aAa");
strings.add("AAaa");
Collections.sort(strings);
for (String s : strings)
{
System.out.print(s + " ");
}
}
}What is the result?
Compilation fails. aAaA aAa AAaa AaA AAaa AaA aAa aAaA AaA AAaa aAaA aAa