LTIMindtree
10+ Globe Detective Agency Interview Questions and Answers
Q1. 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
Q2. 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
Q3. 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
Q4. 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
Q5. 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
Q6. 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
Q7. 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
Q8. 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
Q9. 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
Q10. 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
Q11. types of synchronisation in java
Types of synchronization in Java
Synchronized methods
Synchronized statements
ReentrantLock
Semaphore
CountDownLatch
Q12. 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
Q13. 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
Q14. 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
More about working at LTIMindtree
Top HR Questions asked in Globe Detective Agency
Interview Process at Globe Detective Agency
Top Java Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month