Java Developer Trainee
10+ Java Developer Trainee Interview Questions and Answers for Freshers
Q1. Find the lowest number from an arraylist using streams
Find the lowest number from an arraylist using streams
Use stream.min() method to find the lowest number
Pass Comparator.naturalOrder() to get the lowest number
Handle empty list scenario using OptionalInt
Q2. Wap using control flow Statment to create two object according to input.
Create two objects based on user input using control flow statements in Java.
Use Scanner class to take user input
Use if-else or switch statements to create objects based on input
Instantiate objects with appropriate constructors
Q3. What is map? Explain about collection hierarchy
Map is an interface in Java that maps unique keys to values.
Map is a part of the Java Collections Framework
It is used to store key-value pairs
Some common implementations of Map are HashMap, TreeMap, and LinkedHashMap
Q4. Demonstrate inheritance in java with code
Inheritance in Java allows a class to inherit properties and methods from another class.
Use the 'extends' keyword to create a subclass that inherits from a superclass
The subclass can access all public and protected members of the superclass
Example: class Dog extends Animal { ... }
The 'super' keyword is used to call the superclass constructor or method
Q5. Configuring server port in a spring boot app
To configure server port in a Spring Boot app, modify the application.properties file.
Open the application.properties file
Add the following line: server.port=8080 (or any desired port number)
Save the file and restart the application
Q6. Abstract and anonymous classes in java
Abstract classes are incomplete classes that cannot be instantiated. Anonymous classes are unnamed classes that can be created on the fly.
Abstract classes are declared with the 'abstract' keyword and can have abstract and non-abstract methods.
Anonymous classes are created using the 'new' keyword and can extend a class or implement an interface.
Anonymous classes are often used for event handling and callbacks.
Example of abstract class: abstract class Shape { abstract void draw...read more
Share interview questions and help millions of jobseekers 🌟
Q7. Find duplicate alphabets in a string
Program to find duplicate alphabets in a string
Create a HashMap to store the frequency of each alphabet
Iterate through the string and update the frequency in the HashMap
Iterate through the HashMap and print the alphabets with frequency greater than 1
Q8. Reverse a given string
Reverse a given string
Iterate through the string from end to start and append each character to a new string
Use StringBuilder or StringBuffer for better performance
Convert the string to a character array and swap the first and last characters, then move towards the middle until the entire string is reversed
Java Developer Trainee Jobs
0Q9. Find vowels from a string
A Java program to find vowels from a given string.
Create a string variable and initialize it with the given string.
Use a for loop to iterate through each character of the string.
Check if the character is a vowel using if statement and add it to a new string variable.
Print the new string variable containing all the vowels.
Q10. Explain controller in spring
Controller in Spring is responsible for handling user requests and returning appropriate responses.
Controller receives requests from the client and delegates them to appropriate handlers
It maps the incoming requests to the corresponding handler methods
It returns the response to the client after processing the request
It can also handle exceptions and errors that occur during request processing
Q11. Wap to merge two array.
Merging two arrays of strings in Java.
Create a new array with size equal to the sum of sizes of both arrays.
Copy elements of first array to the new array.
Copy elements of second array to the new array starting from the end of first array.
Return the new array.
Q12. Use of refresh scope
Refresh scope is used in Spring framework to control the lifecycle of beans.
Refresh scope is used to create a new instance of a bean every time it is requested.
It is useful when the state of a bean needs to be reset on every request.
To use refresh scope, add @RefreshScope annotation to the bean definition.
Example: @Bean @RefreshScope public MyBean myBean() { return new MyBean(); }
Interview Questions of Similar Designations
Top Interview Questions for Java Developer Trainee Related Skills
Interview experiences of popular companies
Calculate your in-hand salary
Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary
Reviews
Interviews
Salaries
Users/Month