Hexaware Technologies
10+ Varun Agro Processing Foods Interview Questions and Answers
Q2. What is the new operator used for?
The new operator is used to create an instance of a class or to allocate memory for an object.
The new operator is followed by the name of the class and parentheses.
It can also be used to create arrays of objects.
Example: MyClass obj = new MyClass();
Example: int[] arr = new int[5];
Q4. What is JVM?
JVM stands for Java Virtual Machine. It is an abstract machine that provides a runtime environment for Java programs.
JVM interprets compiled Java code and executes it
It provides platform independence by converting bytecode to machine-specific code
JVM manages memory allocation and garbage collection
Examples of JVM implementations include Oracle JVM, OpenJDK, and IBM JVM
Q7. How hashmap works internally?
Hashmap is a data structure that stores key-value pairs and uses hashing to retrieve values quickly.
Hashmap uses a hash function to convert the key into an index in an array.
Collisions can occur when two keys map to the same index, which is resolved using separate chaining or open addressing.
Hashmap provides constant time complexity O(1) for insertion, deletion, and retrieval of values.
Java's Hashmap implementation uses an array of linked lists to handle collisions.
The load f...read more
Q8. Why string is immutable?
String is immutable to ensure thread safety and prevent unintended modification.
Immutable objects are safer to use in multi-threaded environments as they cannot be changed by other threads.
String pool is possible because of immutability, which saves memory and improves performance.
StringBuffer and StringBuilder classes are used for mutable string operations.
Example: String s = "hello"; s.concat(" world"); // returns a new string, s remains unchanged.
Q9. Difference between List and Set
List allows duplicate elements and maintains insertion order, while Set does not allow duplicates and does not maintain order.
List can contain duplicate elements, Set cannot
List maintains insertion order, Set does not guarantee order
List is implemented by classes like ArrayList, LinkedList, Set is implemented by classes like HashSet, TreeSet
Example: List
list = new ArrayList<>(); Set set = new HashSet<>();
Q10. Comparable vs Comparator
Comparable is an interface used for natural ordering, while Comparator is used for custom ordering in Java.
Comparable interface is used to define the natural ordering of objects. It is implemented by the class whose objects are to be sorted.
Comparator interface is used to define custom ordering of objects. It is implemented by a separate class that compares objects based on specific criteria.
Example: Sorting a list of Strings using Comparable would sort them alphabetically, w...read more
Interview Process at Varun Agro Processing Foods
Top Java Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month