Quizzes
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
ArrayList
:
Content language: English
Русский
Java Collections
ArrayList
What is the result of the following code execution? import java.util.ArrayList; public class Test { public static void main(String[] args) { ArrayList<Integer> array = new ArrayList<Integer>(2); array.add(5); array.add(6); array.add(1, 7); System.out.print(array.indexOf(6)); array.remove(1); System.out.println(array.indexOf(6)); } }
ArrayList
What will be the result of compiling and running the following program? import java.util.ArrayList; import java.util.List; public class Test { public static void main(String a[]) { List<Integer> list = new ArrayList<Integer>(); list.add(null); for (Integer i : list) { System.out.println(i); } } }
ArrayList
What will be the result of compiling and running the following code: import java.util.List; import java.util.ArrayList; public class Test { public static void main(String[] args) { List<String> values = new ArrayList<String>() { { add("one"); add("two"); add("three"); } }; System.out.print("values: "); for (String value : values) { System.out.print(value + " "); } } }
ArrayList
What happens when you'll try to compile and run this code: import java.util.*; public class Clazz { public static void main(String[] args) { List arrayList = new ArrayList(); arrayList.add("str1"); arrayList.add("str2"); arrayList.add("str3"); for (int i = 0; i < arrayList.size(); i++) arrayList.remove(i); System.out.println(arrayList.size()); } }
ArrayList
What will be the result of the following code: import java.util.*; public class Test { public static void main(String[] args) { Class c1 = new ArrayList<String>().getClass(); Class c2 = new ArrayList<Integer>().getClass(); System.out.println(c1 == c2); } }
ArrayList
What will be the result of the code: import java.util.Arrays; import java.util.Iterator; import java.util.List; public class Test { public static void main(String[] args) { String[] str = new String[] { "1", "2", "3" }; List list = Arrays.asList(str); for (Iterator iterator = list.iterator(); iterator.hasNext();) { Object object = (Object) iterator.next(); iterator.remove(); } System.out.println(list.size()); } }
ArrayList
What happens if you run this code: class Test { List<Integer> list; Test(){ list = new ArrayList<Integer>(); someVoid(list); } void someVoid(List<Integer> l){ l.add(0); l=null; } public static void main(String[] args) { Test test=new Test(); System.out.println("Size is: "+test.list.size()); } }
ArrayList
What will happen during the following code execution? import java.util.*; public class Test { public static void main(String[] args) { List a = new ArrayList<Double>();// 4 a.add("1.5");// 5 List<Double> b = new ArrayList();// 6 b.add("1.5");// 7 System.out.println(a + " " + b); } }
ArrayList
What will be the result of the following code compilation and execution? import java.util.*; public class Test { public static void main(String[] args) { List buf = new ArrayList(2); System.out.print(buf.size()); buf.add(10); System.out.print(buf.size()); buf.add(20); buf.add(30); System.out.print(buf.size()); } }
ArrayList
← Prev
1
2
Next →
Sign Up Now
or
Subscribe for future quizzes