Java Developer Trainee

10+ Java Developer Trainee Interview Questions and Answers for Freshers

Updated 10 Sep 2022

Popular Companies

Q1. Find the lowest number from an arraylist using streams

Ans.

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.

Ans.

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

Ans.

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

Ans.

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

Are these interview questions helpful?

Q5. Configuring server port in a spring boot app

Ans.

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

Ans.

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 🌟

man-with-laptop

Q7. Find duplicate alphabets in a string

Ans.

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

Ans.

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

0

Q9. Find vowels from a string

Ans.

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

Ans.

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.

Ans.

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

Ans.

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 Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Interview Questions for Java Developer Trainee Related Skills

Interview experiences of popular companies

3.7
 • 7.3k Interviews
3.8
 • 4.6k Interviews
3.6
 • 2.3k Interviews
4.3
 • 487 Interviews
3.3
 • 165 Interviews
3.7
 • 4 Interviews
View all

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

Java Developer Trainee Interview Questions
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
65 L+

Reviews

4 L+

Interviews

4 Cr+

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