Add office photos
Employer?
Claim Account for FREE

Newgen Software Technologies

3.7
based on 1.4k Reviews
Video summary
Filter interviews by

TCS Interview Questions and Answers

Updated 5 Feb 2024
Popular Designations

Q1. Write a SQL query to find third highest salary from employee table.

Ans.

SQL query to find third highest salary from employee table.

  • Use the ORDER BY clause to sort the salaries in descending order

  • Use the LIMIT clause to limit the result to the third row

  • Use a subquery to exclude the highest and second highest salaries

Add your answer

Q2. Write a program to count occurance the letter in a string.

Ans.

This program counts the occurrence of each letter in a given string.

  • Use a HashMap to store the count of each letter.

  • Iterate through the characters of the string and update the count in the HashMap.

  • Finally, print the count of each letter.

Add your answer

Q3. What is the default size of an arraylist.

Ans.

The default size of an ArrayList is 10.

  • The default initial capacity of an ArrayList is 10.

  • If the number of elements exceeds the initial capacity, the ArrayList automatically increases its size.

  • The capacity of an ArrayList can be increased manually using the ensureCapacity() method.

Add your answer

Q4. what is servlet life cycle

Ans.

Servlet life cycle refers to the sequence of events that occur during the lifespan of a servlet.

  • Servlet is loaded into memory when the server starts

  • init() method is called to initialize the servlet

  • service() method is called to handle client requests

  • destroy() method is called when the servlet is removed from memory

  • Servlet can be reloaded if the server is restarted

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

Q5. what is try with resources

Ans.

Try with resources is a feature introduced in Java 7 to automatically close resources after use.

  • It simplifies the code by eliminating the need for a finally block to close the resource

  • The resource must implement the AutoCloseable interface

  • Multiple resources can be declared in a single try-with-resources statement

  • Example: try(FileInputStream fis = new FileInputStream("file.txt")) { //code }

Add your answer

Q6. Difference between Array and arraylist.

Ans.

Array is a fixed-size data structure while ArrayList is a dynamic-size data structure in Java.

  • Array has a fixed length, while ArrayList can grow dynamically.

  • Array can store both primitive types and objects, while ArrayList can only store objects.

  • Array uses square brackets [] for declaration, while ArrayList uses angle brackets <>.

  • Array provides direct access to elements using index, while ArrayList provides methods for accessing and manipulating elements.

  • Example: String[] nam...read more

Add your answer

Q7. Explain OOPs concepts.

Ans.

OOPs concepts are fundamental principles of object-oriented programming that help in designing and implementing software solutions.

  • Encapsulation: Bundling data and methods together in a class.

  • Inheritance: Creating new classes by inheriting properties and behaviors from existing classes.

  • Polymorphism: Ability of an object to take on many forms.

  • Abstraction: Hiding complex implementation details and providing a simplified interface.

  • Encapsulation, inheritance, and polymorphism tog...read more

Add your answer

Q8. Explain working of Arraylist.

Ans.

ArrayList is a dynamic array that can grow or shrink in size. It stores objects and provides methods for adding, removing, and accessing elements.

  • ArrayList is part of the Java Collections Framework.

  • It is implemented as a resizable array.

  • Elements can be added using the add() method.

  • Elements can be accessed using the get() method.

  • Elements can be removed using the remove() method.

  • The size() method returns the number of elements in the ArrayList.

  • Example: ArrayList names = new Arr...read more

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at TCS

based on 2 interviews
Interview experience
1.5
Bad
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Java Developer Interview Questions from Similar Companies

3.8
 • 53 Interview Questions
3.4
 • 20 Interview Questions
3.9
 • 20 Interview Questions
4.0
 • 16 Interview Questions
3.8
 • 13 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
75 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

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