Important Questions about Java Framework –
1.What is a framework in Java?
A framework is a ready-made architecture .A framework is popular. framework contains a set of classes and interfaces.
2.Explain Collection framework in Java?
It is a group of interfaces and classes . Collection framework used to store and manage the objects. Collection framework provides Different classes like Vector, HashSet, Stack , ArrayList etc. Java Collection can also be used for interfaces like Queue, Set, List, etc.
3.explain What is hashCode()?
The hashCod() is a function that returns an integer hash code.
4.Explain ArrayList in Java?
It is an important data structure useful in handling the dynamic behavior of elements.
For Free, Demo classes Call: 8237077325
Registration Link: Click Here!
5.What does the set explain?
A Set is a Collection .set cannot contain duplicate elements. There are three Set interfaces: HashSet, and LinkedHashSet. HashSet,TreeSet which stores its elements in a hash table, is the best-performing implementation; however it makes no guarantees concerning the order of iteration. it is slower than HashSet. LinkedHashSet, which is implemented as a hash table with a linked list running through it, orders its elements based on the order in which they were inserted into the set (insertion-order).
6.which are the basic interfaces of the Java collections framework?
The Java collection framework represents a group of objects as its elements. Java programming does not provide a direct implementation of interface. Understand all parameters within Java Classes In Pune.
Set: Set is a collection that does not have duplicate elements. Set uses a hashtable for storing elements.
List: The list is like an array having a dynamic length. List is an ordered collection .list can contain duplicate elements. Iist enables developers to access any elements from its inbox.
MAP: MAP is an object which maps keys to values. It cannot contain duplicate keys. every key can be mapped to at least one value.
7. List of collection classes that gives random element access to its elements ?
Collection classes that give random element access are:
1) ArrayList
2) HashMap
3) TreeMap
4) Hashtable.
8.List various classes available in sets ?
Various classes in sets are:
- HashSet,
- TreeSetand
- LinkedHashSet.
9.Which List methods in Java Queue interface?
boolean add(object)
boolean offer(object)
object remove()
object poll()
object element()
object peek()
For Free, Demo classes Call: 8237077325
Registration Link: Click Here!
10. Use of RandomAccess interface?
List implementations use RandomAccess interface for indication that they are supporting fast.
11.Name of the collection classes that implement random access interface?
Java.util package has classes that can implement random access interface are:
CopyOnWriteArrayList, Stack, ArrayList, and Vector.
12 . Use of randomaccess interface?
RandomAccess interface used byList implementations to indicate that they support fast random access. The access is generally constant time.
13 .List of collection classes that implement random access interface?
CopyOnWriteArrayList, Stack, ArrayList, and Vector.
14. Various types of queues in Java?
- Priority queue
- Circular Queue
- Double-ended Queue
15.Difference between ArrayList and Vector in the Java Collection Framework?
- ArrayList –
- It is not synchronized.
- It can increase its size by 50% of the size of the array
- It is not thread-safe.
- It is not a legacy class.
- Vector:
- It is synchronized.
- By doubling its size ,It can increase its size .
- It is thread-safe.
- It is a legacy class.
16 . Types of methods to remove elements from ArrayList?
Following methods are used to remove elements from ArrayList are:
- clear() :- removes the elements from ArrayList.
- remove(int index) :- remove the element at a particular position.
- remove(Object o) :- remove the first occurrence of the mention element from the ArrayList.
- removeAll() :-remove the list of elements that are in a particular collection.
- removeIf(Predicate<? super E> filter) :removes elements that satisfy the mention of a predicate.
17.Explain Iterator vs ListIterator?
1) Iterator is used to traverse List and Set –
List Iterator is used to traverse List only, it cannot traverse Set using ListIterator.
2)Using Iterator We can traversing elements in only forward direction –
ListIterator, can traverse a List in both the directions forward and Backward.
3) Indexes are not obtain while using Iterator –
While traversing a list using ListIterator indexes are obtained at any point of time . for this purpose nextIndex() and previousIndex() methods are used.
4)when use iterator for traversing we cannot add element to collection-
If we try to add element to collection while traversing it will throws ConcurrentModificationException but We can add elements at any point of time while traversing a list using ListIterator.
5) When we use Iterator it cannot replace the existing element value –
In the method of ListIterator we can replace the last element returned by next() or previous() methods.
By using set(E e)
6) Methods of Iterator –
- hasNext()
- next()
- remove()
Methods of ListIterator:
- add(E e)
- hasNext()
- hasPrevious()
- next()
- nextIndex()
- previous()
- previousIndex()
- remove()
- set(E e)
18.Differance between Comparable and Comparator ?
Comparable –
- Comparable is present in the java.lang package.
- Comparable provides compareTo() method for sorting elements.
- The actual class is altered.
- It provides a single sorting sequence.
- In Java Training In Pune, the logic of sorting should be in the same class whose object we want to sort.
Comparator –
- It is present in the java.util package.
- It provides a compare() method for sorting elements.
- The actual class is not altered.
- It provides multiple sorting sequences.
- In Java Course In Pune, the logic of sorting should be in a different class so as to write different sorting based on different attributes of objects.
For Free, Demo classes Call: 8237077325
Registration Link: Click Here!
19. Which are the methods to make collection thread-safe?
The methods are:
- Collections.synchronizedList(list);
- Collections.synchronizedMap(map);
- Collections.synchronizedSet(set);
20.Methods of Deque interface?
- void addFirst(E e): Inserts the specified element at the starting of the Deque.
- void addLast(E e): Inserts the specified element at the end of the Deque.
- boolean contains(Object o): if the specified element is present in the Deque it Returns true.
- E getFirst(): first element of the Deque returns .
- E getLast(): last element of the Deque returns.
- E peekFirst(): if the Deque is empty it will return the first element of Deque, or null.
- E peekLast(): if the Deque is empty it will return the last element of Deque, or null.
- E pollFirst(): if the Deque is empty, if the Deque is empty it will return and remove the first element of Deque, or null .
- E pollLast(): if the Deque is empty it will Returns and removes the last element of Deque, or null
- int size(): Returns the number of elements present in Deque.
Author:-
Call the Trainer and Book your free demo Class Call now!!!
| SevenMentor Pvt Ltd.
© Copyright 2021 | Sevenmentor Pvt Ltd.