Luxoft
10+ Interview Questions and Answers
Q1. What algo Java 8 Garbage collector follow
Java 8 Garbage collector follows the algorithm called G1 (Garbage-First).
G1 divides the heap into regions and collects garbage in small portions called 'garbage-first' regions.
It uses multiple parallel threads for garbage collection.
G1 aims to minimize pause times by dynamically adjusting the amount of garbage collected in each region.
It uses a combination of young and old generation collection to achieve better performance.
G1 also supports concurrent garbage collection, allo...read more
Q2. what is SOLID Principal? and Explain L into it?
SOLID is a set of principles for object-oriented programming. L stands for Liskov Substitution Principle.
SOLID principles help in creating maintainable and scalable software.
Liskov Substitution Principle states that objects of a superclass should be replaceable with objects of its subclasses without affecting the correctness of the program.
This principle ensures that the behavior of the program remains consistent even when objects are replaced with their subtypes.
For example,...read more
Q3. 1)How to calculate time complexity of contains method 2)Java 8 program
Calculating time complexity of contains method in Java 8
Time complexity of contains method in Java 8 is O(n)
It depends on the size of the collection and the type of collection used
For example, for ArrayList, it is O(n), for HashSet, it is O(1)
Java 8 introduced a new method called contains(Object o, Predicate filter) which has a time complexity of O(n)
The contains method is used to check if a collection contains a specific element
Q4. Java 8 feature and explain about each one with examples
Java 8 introduced several new features such as lambda expressions, functional interfaces, streams, and default methods.
Lambda expressions: Allow you to pass functions as arguments to methods, making your code more concise and readable.
Functional interfaces: Interfaces with a single abstract method, used to implement lambda expressions.
Streams: Provide a way to work with sequences of elements and perform operations such as filter, map, and reduce.
Default methods: Allow interfa...read more
Q5. Find sum of distinct elements from two given array.
Sum of distinct elements from two arrays
Create a set to store distinct elements from both arrays
Iterate through each array and add elements to the set
Calculate the sum of elements in the set
Q6. WAP to count Duplicate String using Java 8
WAP to count Duplicate String using Java 8
Use Java 8 Stream API to group and count duplicate strings
Create a Map
to store the count of each string Filter the map to get only the strings with count > 1
Return the size of the filtered map as the number of duplicate strings
Q7. Create Custom annotation
Custom annotations can be created using @interface in Java.
Create a new interface with @interface keyword
Add required elements and default values
Use the annotation by adding @ followed by the annotation name
Example: @CustomAnnotation(value = "example")
Annotations can be used for compile-time checks or runtime behavior
Q8. What is static storage class
Static storage class is used to declare variables that have a lifetime throughout the program execution.
Variables declared with static storage class are initialized only once and retain their value between function calls.
They have a default value of 0 if not initialized explicitly.
Static functions and variables are only visible within the file they are declared in.
Static variables can be used to count the number of times a function is called or to cache values for future use.
Q9. Approach to resolve memory leak
Memory leaks can be resolved by identifying the source of the leak and freeing up the allocated memory.
Use memory profiling tools to identify the source of the leak
Analyze the code to find any unnecessary memory allocations
Ensure all allocated memory is freed up after use
Use smart pointers or garbage collection to automate memory management
Test thoroughly to ensure the issue is resolved
Q10. Memory management in Java 8
Java 8 uses automatic memory management through garbage collection.
Java 8 uses a garbage collector to automatically manage memory.
The garbage collector frees up memory by removing objects that are no longer in use.
Java 8 introduced the G1 garbage collector which is designed to reduce pause times.
Developers can also use tools like jmap and jstat to monitor memory usage.
Q11. Approach to resolve memory
Memory issues can be resolved by identifying and fixing memory leaks, optimizing memory usage, and using appropriate data structures.
Identify and fix memory leaks using tools like Valgrind or AddressSanitizer
Optimize memory usage by reducing unnecessary allocations and deallocations
Use appropriate data structures like arrays, linked lists, and hash tables
Avoid using global variables and excessive recursion
Consider using garbage collection or smart pointers in certain cases
More about working at Luxoft
Interview Process at null
Top Senior Software Engineer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month