Java Collections and Strings
Questions covering Java Collections Framework (ArrayList, Stack, LinkedList, Vector, Queue) and String class methods and operations
Questions
How many constructors are there of ArrayList class in Java?
- 6
- 5
- 4
- 3
- 2
Which of the following methods is present in the Stack class in Java Collections framework?
- remove()
- element()
- Pop()
- poll()
- exit()
Which of the following methods is present in LinkedList class in Java Collections?
- addFirst()
- setFirst()
- setLast()
- indexOf(e:Element)
- lastIndexOf(e:element)
Which of the following methods is/are static in Collections class?
- Frequency(c : collection, o : object)
- Reverse(List)
- Sort(List)
- Both (1) and (2)
- All of the above
Which of the following methods are present in the queue interface?
- poll()
- search(o:Object)
- empty()
- exit()
- pop()
Which of the following methods is/are not present in Vector class in Java Collections framework?
- elementAt(index)
- firstElement()
- removeElementAt(int)
- setSize(int)
- removeFirst()
What is the initial capacity of vector?
- 16
- 10
- 20
- 12
- 18
Which of the following methods in Collections class is not static?
- Min(c : collection)
- Shuffle(list)
- Frequency(c : collection, o : object)
- Copy(destination, source)
- Merge(c : collection, c1 : collection)
Which of the following methods is present in ListIterator interface in Java Collections?
- nextIndex()
- addAll()
- IndexOf()
- listIterator()
- subList(startindex,endindex)
Which of the following methods is/are defined in String class for comparing strings?
- equals(String s)
- compareToIgnoreCase(String s1)
- compareTo(String s3)
- Both (2) and (3)
- All of the above
How many constructors are there of Vector class in Java Collections framework?
- 6
- 5
- 4
- 3
- 2
Which of the following methods is present in Vector class in Java Collections framework?
- removeAllElements()
- element()
- removeLast()
- get(index : int)
- set(index,element)
What will be the output of the given code?
String s = “Welcome To Java” s.substring(4, 4);
- o
- c
- Empty string
- Compile time error
- Run time error
What will be the result of the following code?
String s = “Welcome To Java”; s.charAt(s.length());
- a
- v
- Compiler Error : cannot pass a function as parameter
- Compiler Error : parameters not sufficient
- Run time error
What will be the output of the given program?
class BitShift
{
public static
void main(String [] args)
{
int x = 0x80000000;
System.out.
print(x + and) ;
x = x >>> 31;
System.out.
println(x);
}
}
- -2147483648 and 1
- 0x80000000 and 0x00000001
- -2147483648 and -1
- 1 and -2147483648
- None of these