JAVA
2.7K subscribers
73 photos
111 files
76 links
Download Telegram
public class Program
{
int a;
boolean isTrue;
static int i;
public static void main(String[] args) {
Program p=new Program();
System.out.println(p.a);
System.out.println(p.isTrue);
System.out.println(p.i);
}
}
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);
}
}
public class Program
{
public static void main(String[] args) {
Super s=new SubClass();
s.foo();
}
}
class Super{
void foo(){
System.out.println("Super class");
}
}
class SubClass extends Super{
static void foo(){
System.out.println("SubClass");
}
}
What should we use get operations are more?
Anonymous Quiz
53%
ArrayList
31%
LinkedList
16%
Any
Complexity of ArrayList get method
Anonymous Quiz
21%
O(n-1)
41%
O(n)
29%
O(1)
9%
O(2n)
Which is sorted by natural order?
Anonymous Quiz
26%
LinkedHashSet
47%
TreeSet
20%
HashSet
7%
None
Which of these maintains insertion order?
Anonymous Quiz
51%
List
24%
Set
20%
All
5%
None
Which maintains insertion order?
Anonymous Quiz
29%
TreeSet
25%
HashSet
41%
LinkedHashSet
5%
None
Java HashMap with Realtime Examples
http://www.javachain.com/java-hashmap-with-examples/
In Iterator, hasMoreElements() method of Enumeration has been changed to:
Anonymous Quiz
28%
hasNextElement()
23%
isNext()
44%
hasNext()
5%
name remains same
TreeSet internally uses which one to store elements?
Anonymous Quiz
19%
HashMap
19%
LinkedHashMap
58%
TreeMap
4%
None
HashSet internally uses?
Anonymous Quiz
65%
HashMap
20%
LinkedHashMap
8%
TreeMap
7%
None
An attempt to add null key to a TreeSet will result in:
Anonymous Quiz
14%
Will compile
36%
Compile time Exception
8%
Error
42%
Runtime - NullPointerException
What is initial capacity of LinkedList?
Anonymous Quiz
37%
8
44%
10
19%
16
Enumeration returned by ArrayList is
Anonymous Quiz
49%
Fail-fast
34%
Fail-safe
16%
None