Add office photos
Employer?
Claim Account for FREE

FICO

4.0
based on 200 Reviews
Filter interviews by

Travelurcity Interview Questions and Answers

Updated 19 Apr 2024

Q1. Sort array containing 0s, 1s and 2s

Ans.

Sort an array of 0s, 1s, and 2s in linear time complexity.

  • Use three pointers to keep track of the positions of 0s, 1s, and 2s.

  • Traverse the array and swap elements to their respective positions.

  • Time complexity: O(n), Space complexity: O(1).

Add your answer

Q2. Why is string immutable in java?

Ans.

String is immutable in Java to ensure security, thread safety, and optimization.

  • Immutable strings are thread-safe as they cannot be modified concurrently by multiple threads.

  • String pooling allows Java to optimize memory usage by reusing common string literals.

  • Immutable strings prevent security vulnerabilities like SQL injection attacks.

Add your answer

Q3. Abstract class vs interface

Ans.

Abstract class is a class that cannot be instantiated, while an interface is a contract that a class must implement.

  • Abstract classes can have implemented methods, while interfaces cannot

  • A class can implement multiple interfaces, but can only inherit from one abstract class

  • Interfaces are used for achieving multiple inheritance in Java

  • Abstract classes are used for creating a base class for other classes to inherit from

  • Example of abstract class: public abstract class Animal { pu...read more

View 1 answer

Q4. Spiral order traversal of BST.

Ans.

Spiral order traversal of BST

  • Use two stacks to traverse the tree in a spiral order

  • Push the root node into the first stack

  • While the first stack is not empty, pop a node and print its value

  • Push its left and right children into the second stack

  • Once the first stack is empty, swap the stacks and repeat the process

  • Continue until both stacks are empty

View 1 answer
Discover Travelurcity interview dos and don'ts from real experiences

Q5. Hashmap vs hashset

Ans.

Hashmap is a key-value pair data structure while Hashset is a set of unique values.

  • Hashmap allows duplicate values but not duplicate keys.

  • Hashset does not allow duplicate values.

  • Hashmap is implemented using a combination of hash table and linked list.

  • Hashset is implemented using only a hash table.

  • Example of Hashmap: {1:'one', 2:'two', 3:'three'}

  • Example of Hashset: {'apple', 'banana', 'orange'}

Add your answer

Q6. Arraylist vs hashmap

Ans.

ArrayList is a resizable array while HashMap is a key-value pair data structure.

  • ArrayList is ordered and allows duplicates while HashMap is unordered and does not allow duplicate keys.

  • ArrayList is accessed by index while HashMap is accessed by key.

  • ArrayList is suitable for storing and accessing elements sequentially while HashMap is suitable for fast lookup of values by key.

  • Example: ArrayList - List names = new ArrayList<>(); names.add("John"); names.add("Jane");

  • Example: Hash...read more

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Engineer Interview Questions from Similar Companies

3.5
 • 48 Interview Questions
4.1
 • 46 Interview Questions
3.7
 • 24 Interview Questions
3.1
 • 10 Interview Questions
3.5
 • 10 Interview Questions
2.0
 • 10 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter