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
collections
:
Content language: English
Русский
Java Collections
collections
Which data structure that implements a Map interface uses an == operator, rather than the equals method for objects comparison?
collections
Which interfaces extend a Collection interface?
collections
What will happen after the following code compilation and execution: class TreeTest { private static Set<String> set = new TreeSet<String>(); public static void main(String[] args) { set.add("one"); set.add("two"); set.add("three"); set.add("/u000a"); set.add("/u000d"); set.add("/u000c"); set.add("1"); set.add("2"); set.add("3"); for (String string : set) { System.out.print(string + " "); } } }
collections
What will be printed after the following code execution? import java.util.*; public class MapTest { public static void main( String[] args ) { Map<String, Integer> map1 = new HashMap<String, Integer>(); Map<String, Integer> map2 = new HashMap<String, Integer>(); map1.put( "Number1", new Integer( 100 ) ); map1.put( "Number2", new Integer( 200 ) ); map1.put( "Number3", new Integer( 300 ) ); List<Map> list = new ArrayList<Map>(); list.add( map1 ); list.add( map2 ); HashMap resultMap = (HashMap) list.get( 0 ); System.out.println( "Number: " + resultMap.get( "Number2" ) ); } }
collections
What interfaces provide the ability to store objects as a "key-value" pairs?
collections
What will be the following code execution result? class HashTest { private static Set<String> set = new LinkedHashSet<String>(); public static void main(String[] args) { set.add("one"); set.add("two"); set.add("three"); set.add("two"); for (String string : set) { System.out.print(string + " "); } } }
collections
What will the following code's execution print to console? import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; public class Test { private static void removeAndPrint(List<String> list) { for (String str : list) { if (str.equals("two")) { list.remove("three"); } } System.out.println(list); } public static void main(String[] args) { List<String> list = new CopyOnWriteArrayList<String>(); list.add("one"); list.add("two"); list.add("three"); list.add("four"); removeAndPrint(list); } }
collections
Will the following code compile? public class GenericTest { public static void main(String[] args) { List<double> myList = new ArrayList<double>(); } }
collections
What is the result of the following code execution? package tests; import java.util.Hashtable; public class Test { public static void main(String[] args) { Hashtable ht = new Hashtable(); ht.put("1", "2"); ht.put("2", "3"); ht.put("3", "4"); ht.put("4", "2"); if(ht.contains("1")){ System.out.print("1"); } if(ht.contains("2")){ System.out.print("2"); } if(ht.contains("3")){ System.out.print("3"); } if(ht.contains("4")){ System.out.print("4"); } } }
collections
← Prev
1
2
Next →
Sign Up Now
or
Subscribe for future quizzes