LTIMindtree
30+ Weatherford Interview Questions and Answers
You are given an array ‘ARR’ of 'N' integers. Your task is to find the longest harmonious subsequence of this array.
A sequence is Harmonious if the difference between the maximum ...read more
Difference between static and final
Difference between ArrayList and HashMap in Java
Q7. 3. How can we make a class immutable in java?
To make a class immutable in Java, we need to follow certain guidelines.
Make the class final
Make all fields private and final
Do not provide setter methods
If the field is mutable, return a clone of it instead of the original object
Ensure that any mutable objects passed to the constructor are not modified outside the class
Q8. what is autoboxing and unboxing
Autoboxing is the automatic conversion of primitive data types to their corresponding object wrapper classes.
Autoboxing is useful when working with collections that require objects instead of primitives.
Example: int i = 5; Integer j = i; //autoboxing
Unboxing is the opposite of autoboxing, where an object of a wrapper class is converted back to its corresponding primitive type.
Example: Integer j = 5; int i = j; //unboxing
Q9. Write a program to add numbers in harmonic series. (1+1/2+1/3+.....1/n)
Program to add numbers in harmonic series (1+1/2+1/3+...+1/n)
Create a variable to store the sum
Use a loop to iterate through the series up to n
Add each term to the sum
Print the sum
Q10. 1. Difference between finally and static block?
finally is used to execute a block of code after try-catch block, while static block is executed when class is loaded.
finally block is used to perform cleanup operations like closing database connections, file streams etc.
static block is used to initialize static variables or perform any other static initialization.
finally block is always executed whether an exception is thrown or not, while static block is executed only once when class is loaded.
finally block is always writt...read more
Q11. Difference between arrayList and vector and Hashmap and hashtable?
ArrayList and Vector are similar but Vector is synchronized while HashMap and HashTable are both key-value pair data structures but HashTable is synchronized.
ArrayList and Vector both implement List interface but Vector is thread-safe while ArrayList is not.
Vector is slower than ArrayList due to synchronization.
HashMap and HashTable both store key-value pairs but HashTable is thread-safe while HashMap is not.
HashMap allows null keys and values while HashTable does not.
HashMap...read more
Q12. what is typecasting UP AND DOWN
Typecasting up and down refers to converting a variable of one data type to another data type of higher or lower precision.
Typecasting up involves converting a variable of lower precision to a variable of higher precision, such as converting an int to a double.
Typecasting down involves converting a variable of higher precision to a variable of lower precision, such as converting a double to an int.
Typecasting can result in loss of data or precision.
Typecasting can be done imp...read more
Q13. What are new features in Java 8 explain in brief
Java 8 introduced new features like lambda expressions, functional interfaces, streams, and default methods.
Lambda expressions allow you to write code in a more concise and readable way.
Functional interfaces provide a single abstract method for functional programming.
Streams enable processing sequences of elements in a functional style.
Default methods allow interfaces to have method implementations.
Example: Lambda expression - (a, b) -> a + b
Example: Functional interface - Co...read more
Q14. 4. What are collections in java?
Collections are data structures that store and manipulate groups of objects.
Collections provide a way to manage and manipulate groups of objects
Java provides several built-in collection classes such as ArrayList, LinkedList, HashSet, etc.
Collections can be used to perform operations like searching, sorting, filtering, etc.
Collections can store objects of any type, including primitive types and user-defined classes
Q15. 2. Use of @autowired annotation in spring?
The @Autowired annotation in Spring is used to automatically wire dependencies into a bean.
It eliminates the need for manual wiring of dependencies
It can be used to inject dependencies into constructors, fields, and methods
It can be used with other annotations like @Qualifier and @Value
It can be used with both XML and Java-based configurations
Q16. which design pattern to use for complex design?
Use the Strategy design pattern for complex design.
Strategy pattern allows you to define a family of algorithms, encapsulate each one, and make them interchangeable.
It helps in separating the behavior of a class from the class itself, making it easier to switch between different algorithms at runtime.
Examples of using Strategy pattern include implementing different sorting algorithms in a class or defining various payment methods in an e-commerce application.
Q17. how do you iterate map
To iterate a map in Java, use a for-each loop or an iterator.
Use the entrySet() method to get a set of key-value pairs
For-each loop: for(Map.Entry
entry : map.entrySet()) Iterator: Iterator
> iterator = map.entrySet().iterator(); Use hasNext() and next() methods to iterate through the map
Q18. types of synchronisation in java
Types of synchronization in Java
Synchronized methods
Synchronized statements
ReentrantLock
Semaphore
CountDownLatch
Q19. What does you know about oops
OOPS stands for Object-Oriented Programming System. It is a programming paradigm based on the concept of objects.
OOPS is based on four main concepts: Encapsulation, Inheritance, Polymorphism, and Abstraction.
Encapsulation is the process of hiding the implementation details of an object from the outside world.
Inheritance allows a class to inherit properties and methods from another class.
Polymorphism allows objects of different classes to be treated as if they were of the same...read more
Q20. access modifiers in method overriding
Access modifiers in method overriding
Access modifiers in the overriding method cannot be more restrictive than the overridden method
The access modifier can be less restrictive or the same as the overridden method
Private methods cannot be overridden
Examples: public method can be overridden by public or protected method, but not by private method
Q21. What is JVM? what is JIT
JVM stands for Java Virtual Machine, which is an abstract computing machine that enables a computer to run Java programs. JIT stands for Just-In-Time compiler, which compiles Java bytecode into native machine code at runtime for improved performance.
JVM is responsible for executing Java programs by converting Java bytecode into machine code that can be understood by the computer's operating system.
JIT is a component of the JVM that improves the performance of Java application...read more
Q22. What is Rest Api?
Rest Api is a web service that uses HTTP methods to access and manipulate data.
Rest stands for Representational State Transfer
It is an architectural style for building web services
Uses HTTP methods like GET, POST, PUT, DELETE
Data is transferred in JSON or XML format
Examples: Twitter API, Facebook Graph API
Q23. Map vs flatmap in java 8, Volatile keyword,
Map applies a function to each element in a stream, while flatMap applies a function that returns a stream for each element.
Map transforms each element in a stream using a function, returning a new stream of transformed elements.
FlatMap transforms each element in a stream using a function that returns a stream, then flattens the streams into a single stream.
Volatile keyword in Java is used to indicate that a variable's value will be modified by different threads.
Q24. Create a rest service using spring boot
Create a REST service using Spring Boot
Create a new Spring Boot project
Add dependencies for Spring Web and Spring Boot DevTools in pom.xml
Create a new Java class for the REST controller with @RestController annotation
Define request mapping annotations like @GetMapping, @PostMapping, @PutMapping, @DeleteMapping for different HTTP methods
Implement the business logic for each endpoint
Run the Spring Boot application and test the REST service using tools like Postman
Q25. What is spring actuator
Spring Actuator is a feature in Spring Boot that provides monitoring and management capabilities for your application.
Spring Actuator exposes various endpoints to monitor and manage your application, such as /health, /info, /metrics, etc.
It allows you to check the health of your application, gather metrics, view application properties, and more.
You can also create custom endpoints for specific monitoring needs.
Spring Actuator is commonly used in production environments to mon...read more
Q26. explain different phases of sdlc
SDLC stands for Software Development Life Cycle, which consists of different phases from planning to maintenance.
1. Planning phase involves defining project scope, requirements, and creating a project plan.
2. Analysis phase focuses on gathering and analyzing requirements to create a detailed system design.
3. Design phase involves creating a high-level design, detailed design, and architecture for the software.
4. Implementation phase is where the actual coding and development ...read more
Q27. callable vs runnable?
Callable is used to return a result and can throw checked exceptions, while Runnable is used for void operations.
Callable can return a result and throw checked exceptions, while Runnable cannot.
Callable is a functional interface with a method call() that returns a result, while Runnable is a functional interface with a method run() that does not return a result.
Example: Callable
task = () -> { return 5 + 3; }; Runnable task = () -> { System.out.println("Hello World!"); };
Q28. 4 paillers of datastructure.
The 4 pillars of data structure are arrays, linked lists, stacks, and queues.
Arrays: Data structure that stores a collection of elements with a fixed size.
Linked Lists: Data structure where each element points to the next element in the sequence.
Stacks: Data structure that follows the Last In First Out (LIFO) principle.
Queues: Data structure that follows the First In First Out (FIFO) principle.
Q29. spring vs spring boot
Spring is a framework for building Java applications, while Spring Boot is a tool for quickly creating standalone Spring-based applications.
Spring is a comprehensive framework for building Java applications, providing support for various modules like Spring MVC, Spring Security, and Spring Data.
Spring Boot is a tool that simplifies the process of setting up and configuring a Spring application, by providing defaults and auto-configuration.
Spring Boot includes embedded servers...read more
Q30. Annotations in springboot
Annotations in Spring Boot are used to provide metadata about the application and its components.
Annotations are used to configure Spring Boot applications, define beans, handle requests, etc.
Examples include @RestController, @Autowired, @RequestMapping, @Component, etc.
Q31. Explain Streams
Streams in Java are sequences of elements that support functional-style operations.
Streams allow for processing sequences of elements in a functional style.
They can be created from various data sources like collections, arrays, or I/O channels.
Operations on streams can be intermediate (e.g. filter, map) or terminal (e.g. forEach, collect).
Streams promote parallel processing and lazy evaluation for improved performance.
Example: List
names = Arrays.asList("Alice", "Bob", "Charl...read more
Q32. Working of HashMap
HashMap is a data structure in Java that stores key-value pairs and allows fast retrieval of values based on keys.
HashMap uses hashing to store key-value pairs, which allows for fast retrieval of values.
Keys in a HashMap must be unique, but values can be duplicated.
HashMap allows null keys and null values.
HashMap is not synchronized, so it is not thread-safe. To make it thread-safe, you can use ConcurrentHashMap.
Example: HashMap
map = new HashMap<>(); map.put("apple", 5); int...read more
More about working at LTIMindtree
Interview Process at Weatherford
Top Java Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month