HARMAN
10+ Interview Questions and Answers
Q1. Write a method for deletion of a node from a Linked List.
Method for deleting a node from a Linked List
Find the node to be deleted
Update the previous node's next pointer to skip the deleted node
Free the memory occupied by the deleted node
Q2. Write a code to check if two strings are anagrams of each other.
Code to check if two strings are anagrams of each other.
Create two character arrays from the strings
Sort the arrays
Compare the sorted arrays
Q3. How to make a custom immutable class in java?
Creating a custom immutable class in Java
Make the class final
Make all fields private and final
Do not provide any setter methods
Provide a constructor to initialize all fields
Override equals() and hashCode() methods
Prevent modification of mutable objects passed in constructor
Q4. why is string immutable
String is immutable because it ensures data integrity and allows for efficient memory management.
Immutable strings prevent accidental modification of data.
Immutable strings can be easily shared and reused, improving memory efficiency.
Immutable strings enable efficient string interning and caching.
Immutable strings support thread safety in concurrent environments.
Q5. Time complexity of linked lists operations
Time complexity of linked list operations is O(n) for traversal, insertion and deletion.
Traversal, insertion and deletion in linked lists take linear time.
Insertion and deletion at the beginning of the list is faster than at the end.
Doubly linked lists have slightly higher time complexity due to maintaining two pointers.
Q6. do @requestparam has default value
Yes, @RequestParam has a default value if not specified.
If a @RequestParam is not provided in the request, it will use its default value.
The default value can be set using the 'defaultValue' attribute of @RequestParam annotation.
If no default value is specified, the parameter will be considered as required and an exception will be thrown if not provided.
Q7. why abstract class is required
Abstract classes are required to provide a common interface and share code among related classes.
Abstract classes allow for code reusability and promote modular design.
They provide a common interface for a group of related classes.
Abstract classes can define abstract methods that must be implemented by subclasses.
They can also provide default implementations for common methods.
Abstract classes cannot be instantiated, but can be used as a reference type.
Q8. what is using namespace std; ?
using namespace std; is a directive in C++ that allows the programmer to use all elements of the standard C++ library without specifying the std:: prefix.
It is used to avoid having to write std:: before standard library elements.
It should be used with caution as it can lead to naming conflicts.
Example: cout << 'Hello, World!'; instead of std::cout << 'Hello, World!';
Q9. How to reverse a string?
To reverse a string, iterate through the string and append each character to a new string in reverse order.
Create an empty string to store the reversed string
Iterate through the original string from the end to the beginning
Append each character to the new string
Return the new string
Q10. what is polymorphism ?
Polymorphism is the ability of a function or method to behave differently based on the object it is acting upon.
Polymorphism allows objects of different classes to be treated as objects of a common superclass.
There are two types of polymorphism: compile-time (method overloading) and runtime (method overriding).
Example: Animal class with methods like eat() can be inherited by classes like Dog and Cat, which can override the eat() method.
Q11. why we need ood ?
OOD (Object-Oriented Design) is essential for creating modular, reusable, and maintainable software systems.
OOD helps in organizing code into manageable components
Encourages code reusability through inheritance and polymorphism
Facilitates easier maintenance and updates
Promotes scalability and flexibility in software development
Enables better collaboration among team members
Q12. write sorting algorithm ?
A sorting algorithm is a method used to arrange elements in a specific order.
Common sorting algorithms include Bubble Sort, Selection Sort, Insertion Sort, Merge Sort, Quick Sort, and Heap Sort.
Bubble Sort compares adjacent elements and swaps them if they are in the wrong order.
Merge Sort divides the array into two halves, sorts them separately, and then merges them back together.
Quick Sort picks a pivot element and partitions the array around the pivot.
Heap Sort builds a max...read more
More about working at HARMAN
Interview Process at null
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month