JAVA
2.7K subscribers
73 photos
111 files
76 links
Download Telegram
Which of the following is true about the use of modifiers?
(a)
If no accessibility modifier (public, protected, and private) is specified for a member declaration, the member is only accessible for classes in the package of its class and subclasses of its class anywhere
(b)
You cannot specify accessibility of local variables. They are only accessible within the block in which they are declared
(c)
Subclasses of a class must reside in the same package as the class they extend
(d)
Local variables can be declared static
(e)
None of the above.
public class Program
{
public static void main(String[] args) {
try{
int[] a={1,2,3,4};
for(int i=1;i<=4;i++){
System.out.println("a["+i+"]="+a[i]+"\n");
}
}
catch(Exception e){
System.out.println("error="+e);
}
catch(ArrayIndexOutOfBoundsException e){
System.out.println("ArrayIndexOutOfBoundsException");
}
}
}
A)Compile Time Error
B) Runtime Error
C) Error Code is printed
D) Array is printed
In Iterator, hasMoreElements() method of Enumeration has been changed to:
Anonymous Quiz
16%
hasNextElement()
11%
isNext()
63%
hasNext()
11%
name remains same
TreeSet internally uses that one to store elements?
Anonymous Quiz
27%
HashMap
23%
LinkedHashMap
50%
TreeMap
HashSet internally uses?
Anonymous Quiz
75%
HashMap
15%
LinkedHashMap
10%
TreeMap
An attempt to add the null key to a TreeSet will result in:
Anonymous Quiz
16%
Will compile
53%
Compile time Exception
11%
Error
21%
Runtime - NullPointerException
TreeSet maintains which order?
Anonymous Quiz
57%
Ascending Order
19%
Descending Order
24%
None of the above
Enumeration returned by ArrayList is
Anonymous Quiz
43%
Fail-fast
48%
Fail-safe
10%
None of the above
The Comparator interface contains the method?
Anonymous Quiz
27%
compareWith()
45%
compareTo()
27%
compare()
What will Collections.sort internally uses when number of elements are less than 7?
Anonymous Quiz
28%
Insertion sort
22%
Merge sort
50%
Quick sort
What do Collections.sort internally uses once a number of elements are greater than 7?
Anonymous Quiz
22%
Insertion sort
44%
Merge sort
33%
Quick sort
An attempt to add null key to a TreeMap will result in:
Anonymous Quiz
22%
Compile time Exception
17%
Error
61%
Runtime - NullPointerException
What will be the output of the following code -
import java.util.Map;
import java.util.TreeMap;
public class TreeMapTest
{
public static void main(String[] args) {
Map<Integer,String> m=new TreeMap<Integer,String>();
m.put(11,"audi");
m.put(null,null);
m.put(11,"bmw");
m.put(null,"fer");
System.out.println(m.size());
System.out.println(m);
}
}