In java, collection interview questions are mostly asked by the interviewers. Here is the list of mostly asked collections interview questions with answers.1) What is the difference between ArrayList and Vector?No.ArrayListVector 1) ArrayList is not synchronized. Vector is synchronized....
Garbage collection is one of the most important feature of Java. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory. User program cann't directly free the object from memory, instead it is the jo...
public class Fruits{public static void main (String [ ] args){ArrayList <String>names=new ArrayList <String>();names.add (“apple”);names.add (“cherry”);names.add (“kiwi”);names.add (“banana”);names.add (“cherry”);System.out.println (names);}}Output: [Apple, cherry, kiwi,...
All the methods of Vector is synchronized. But, the methods of ArrayList is not synchronized. Vector is a Legacy class added in first release of JDK. ArrayList was part of JDK 1.2, when collection framework was introduced in java. By default, Vector doubles the size of its array when it ...
17. Can we passArrayList<Integer>to a method which acceptsList<Number>? (No) How to fix that? (use wildcards e.g.List<? extends Number>to know more about bounded and unbounded wildcards and other generics questions see thispost)
12 Why java is not pure object oriented language 13 What is the difference between abstract class and interface 14 What are marker interfaces 15 What are collections in Java? 16 What are the differences between arraylist and vector? 17 What is finalize method? How do you override it? 18 Wha...
Java Collections Interview Questions and AnswersWhat are Collection related features in Java 8? Java 8 has brought major changes in the Collection API. Some of the changes are: Java Stream API for collection classes for supporting sequential as well as parallel processing Iterable interface is ...
–ArrayList: unsynchronized, fasterand not thread safe. –Vector: Synchronized, slower and thread-safe. 62) What are thedifferences between Heap and Stack Memory in Java? Heap: Holds objects and isshared between threads. Stack — A storagefacility for local variables and method calls, thread-spe...
importjava.util.Stack; publicclassConvexHull { //assume no duplicate points publicstaticvoidmain(String [] args) { ArrayList<Point> points =newArrayList<Point> (); points.add(newPoint(0,0)); points.add(newPoint(1,1)); points.add(newPoint(3,10)); ...
Looking forward to appear in Java Interview, here are the key Java Interview Questions with Answers only for you. - aatul/Java-Interview-Questions-Answers