Add office photos
Engaged Employer

Fluentgrid

3.9
based on 222 Reviews
Filter interviews by

OpsTree Solutions Interview Questions and Answers

Updated 2 Oct 2024

Q1. Given a ArrayList of String containing some name with some name repeated. Write the code on a notepad printing only the single occurrence of each name in the ArrayList. iImplement the same using Java 8 Streams ...

read more
Ans.

Using Java 8 Streams API to print single occurrences of names in an ArrayList of Strings.

  • Use stream() method on the ArrayList to create a stream of elements.

  • Use filter() method to filter out elements that occur more than once.

  • Use distinct() method to get only unique elements.

  • Use forEach() method to print each unique element.

Add your answer

Q2. You are given a string, name and an integer which is year of birth. You need to print the reverse of year of birth followed by the reverse of name.

Ans.

Reverse the year of birth and name, then print them in that order.

  • Reverse the year of birth using StringBuilder.reverse() method

  • Reverse the name using StringBuilder.reverse() method

  • Print the reversed year of birth followed by the reversed name

Add your answer

Q3. Given a ArrayList of String containing some names with some repeated names. Write the code on a notepad printing each name and the number of occurrences of each name in the ArrayList

Ans.

Code to print each name and the number of occurrences in an ArrayList of Strings.

  • Iterate through the ArrayList and use a HashMap to store the count of each name.

  • Print each name along with its count from the HashMap.

Add your answer

Q4. What are Interfaces and Abstract classed in Java and code an example of an interface on Notepad

Ans.

Interfaces and Abstract classes in Java are used for achieving abstraction and defining contracts for classes to implement.

  • Interfaces in Java are like blueprints for classes, defining methods that must be implemented by classes that implement the interface.

  • Abstract classes are classes that cannot be instantiated and can have both abstract and concrete methods.

  • Example of an interface in Java: public interface Shape { double calculateArea(); double calculatePerimeter(); }

  • Exampl...read more

Add your answer
Discover OpsTree Solutions interview dos and don'ts from real experiences

Q5. What are lambda expressions in Java

Ans.

Lambda expressions in Java are a concise way to represent anonymous functions.

  • Lambda expressions are used to provide implementation of functional interfaces.

  • They enable you to treat functionality as a method argument, or code as data.

  • Syntax: (parameters) -> expression or (parameters) -> { statements; }

  • Example: (int a, int b) -> a + b

Add your answer

Q6. What are functional interfaces in Java

Ans.

Functional interfaces in Java are interfaces with only one abstract method, used for lambda expressions and functional programming.

  • Functional interfaces have only one abstract method, but can have multiple default or static methods.

  • They are used for lambda expressions and functional programming in Java.

  • Examples include java.lang.Runnable, java.util.Comparator, and java.util.function.Function.

Add your answer

Q7. What are Threads in Java

Ans.

Threads in Java are lightweight sub-processes that allow concurrent execution within a single process.

  • Threads allow multiple tasks to be executed simultaneously in a Java program.

  • Threads share the same memory space and resources within a process.

  • Example: Creating a new thread using the Thread class or implementing the Runnable interface.

Add your answer

Q8. What are Streams in Java

Ans.

Streams in Java are sequences of elements that support functional-style operations such as filter, map, reduce, etc.

  • Streams are not data structures, but rather a way to interact with collections of objects.

  • They allow for efficient processing of large amounts of data.

  • Streams can be sequential or parallel, allowing for concurrent processing.

  • Example: List names = Arrays.asList("Alice", "Bob", "Charlie"); Stream stream = names.stream();

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 Java Developer Interview Questions from Similar Companies

3.6
 • 51 Interview Questions
4.0
 • 18 Interview Questions
3.5
 • 16 Interview Questions
4.0
 • 14 Interview Questions
4.4
 • 11 Interview Questions
3.6
 • 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