Which Set class must be preferred in multi-threading environment, considering performance constraint
Anonymous Quiz
12%
HashSet
35%
ConcurrentSkipListSet
35%
LinkedHashSet
19%
CopyOnWriteArraySet
Which Map class must be preferred in multi-threading environment, considering performance constraint
Anonymous Quiz
33%
Hashtable
19%
CopyOnWriteMap
48%
ConcurrentHashMap
0%
ConcurrentMap
import java.util.HashSet;
import java.util.Set;
public class Program
{
public static void main(String[] args) {
Set hashSet=new HashSet();
hashSet.add("1");
hashSet.add(1);
hashSet.add(null);
hashSet.add("null");
System.out.println(hashSet);
}
}
import java.util.Set;
public class Program
{
public static void main(String[] args) {
Set hashSet=new HashSet();
hashSet.add("1");
hashSet.add(1);
hashSet.add(null);
hashSet.add("null");
System.out.println(hashSet);
}
}
import java.util.HashMap;
import java.util.Map;
public class Program
{
public static void main(String[] args) {
Map<String,String> hashMap=new HashMap<String,String>();
hashMap.put(new String("a"),"audi");
hashMap.put(new String("a"),"ferari");
System.out.println(hashMap);
}
}
import java.util.Map;
public class Program
{
public static void main(String[] args) {
Map<String,String> hashMap=new HashMap<String,String>();
hashMap.put(new String("a"),"audi");
hashMap.put(new String("a"),"ferari");
System.out.println(hashMap);
}
}
import java.util.IdentityHashMap;
import java.util.Map;
public class Program
{
public static void main(String[] args) {
Map<String,String> identityHashMap=new IdentityHashMap<String,String>();
identityHashMap.put(new String("a"),"audi");
identityHashMap.put(new String("a"),"ferari");
System.out.println(identityHashMap);
}
}
import java.util.Map;
public class Program
{
public static void main(String[] args) {
Map<String,String> identityHashMap=new IdentityHashMap<String,String>();
identityHashMap.put(new String("a"),"audi");
identityHashMap.put(new String("a"),"ferari");
System.out.println(identityHashMap);
}
}
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class Program
{
public static void main(String[] args) {
Map<Integer,String> hashMap=new HashMap<Integer,String>();
hashMap.put(11,"a");
Collections.unmodifiableMap(hashMap);
hashMap.put(12,"b");
System.out.println(hashMap);
}
}
import java.util.HashMap;
import java.util.Map;
public class Program
{
public static void main(String[] args) {
Map<Integer,String> hashMap=new HashMap<Integer,String>();
hashMap.put(11,"a");
Collections.unmodifiableMap(hashMap);
hashMap.put(12,"b");
System.out.println(hashMap);
}
}
Options
Anonymous Quiz
17%
{11=a}
48%
{11=a, 12=b}
17%
UnsupportedOperationException
17%
Compile time exception
import java.util.Hashtable;
import java.util.Map;
public class Program
{
public static void main(String[] args) {
Map<Integer,String> hashtable=new Hashtable<Integer,String>();
hashtable.put(11,"a");
hashtable.put(null,"c");
hashtable.put(null,null);
System.out.println(hashtable.size());
System.out.println(hashtable);
}
}
import java.util.Map;
public class Program
{
public static void main(String[] args) {
Map<Integer,String> hashtable=new Hashtable<Integer,String>();
hashtable.put(11,"a");
hashtable.put(null,"c");
hashtable.put(null,null);
System.out.println(hashtable.size());
System.out.println(hashtable);
}
}
Options
Anonymous Quiz
35%
Runtime Exception
23%
Compile time exception
27%
{11=a, null=c}
15%
{11=a, null=null}
import java.util.HashMap;
class Employee{
private String name;
public Employee(String name){
this.name=name;
}
public int hashCode(){
return 1;
}
}
public class Program
{
public static void main(String[] args) {
HashMap<Employee,String> hashMap=new HashMap<Employee,String>();
hashMap.put(new Employee("a"),"emp1");
hashMap.put(new Employee("b"),"emp2");
hashMap.put(new Employee("a"),"emp1 overridden");
System.out.println(hashMap.size());
System.out.println(hashMap.get(new Employee("a")));
}
}
class Employee{
private String name;
public Employee(String name){
this.name=name;
}
public int hashCode(){
return 1;
}
}
public class Program
{
public static void main(String[] args) {
HashMap<Employee,String> hashMap=new HashMap<Employee,String>();
hashMap.put(new Employee("a"),"emp1");
hashMap.put(new Employee("b"),"emp2");
hashMap.put(new Employee("a"),"emp1 overridden");
System.out.println(hashMap.size());
System.out.println(hashMap.get(new Employee("a")));
}
}
import java.util.HashMap;
class Employee{
private String name;
public Employee(String name){
this.name=name;
}
public boolean equals(Object obj){
return true;
}
}
public class Program
{
public static void main(String[] args) {
HashMap<Employee,String> hashMap=new HashMap<Employee,String>();
hashMap.put(new Employee("a"),"emp1");
hashMap.put(new Employee("b"),"emp2");
hashMap.put(new Employee("a"),"emp1 overridden");
System.out.println(hashMap.size());
System.out.println(hashMap.get(new Employee("a")));
}
}
class Employee{
private String name;
public Employee(String name){
this.name=name;
}
public boolean equals(Object obj){
return true;
}
}
public class Program
{
public static void main(String[] args) {
HashMap<Employee,String> hashMap=new HashMap<Employee,String>();
hashMap.put(new Employee("a"),"emp1");
hashMap.put(new Employee("b"),"emp2");
hashMap.put(new Employee("a"),"emp1 overridden");
System.out.println(hashMap.size());
System.out.println(hashMap.get(new Employee("a")));
}
}
import java.util.HashMap;
class Employee{
private String name;
public Employee(String name){
this.name=name;
}
public int hashCode(Object obj){
return (this.name==null ? 0: this.name.hashCode());
}
}
public class Program
{
public static void main(String[] args) {
HashMap<Employee,String> hashMap=new HashMap<Employee,String>();
hashMap.put(new Employee("a"),"emp1");
hashMap.put(new Employee("b"),"emp2");
hashMap.put(new Employee("a"),"emp1 overridden");
System.out.println(hashMap.size());
System.out.println(hashMap.get(new Employee("a")));
}
}
class Employee{
private String name;
public Employee(String name){
this.name=name;
}
public int hashCode(Object obj){
return (this.name==null ? 0: this.name.hashCode());
}
}
public class Program
{
public static void main(String[] args) {
HashMap<Employee,String> hashMap=new HashMap<Employee,String>();
hashMap.put(new Employee("a"),"emp1");
hashMap.put(new Employee("b"),"emp2");
hashMap.put(new Employee("a"),"emp1 overridden");
System.out.println(hashMap.size());
System.out.println(hashMap.get(new Employee("a")));
}
}
An overview of HTTP - HTTP | MDN
https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview
https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview
MDN Web Docs
Overview of HTTP - HTTP | MDN
HTTP is a protocol for fetching resources such as HTML documents.
It is the foundation of any data exchange on the Web and it is a client-server protocol, which means requests are initiated by the recipient, usually the Web browser.
A complete document is…
It is the foundation of any data exchange on the Web and it is a client-server protocol, which means requests are initiated by the recipient, usually the Web browser.
A complete document is…