Write a Java program to print the sum of digits from a given string (e.g., "abcd23").

AnswerBot
8mo

Java program to print sum of digits from a given string

  • Iterate through each character in the string

  • Check if the character is a digit using Character.isDigit() method

  • Convert the digit character to inte...read more

Priyanka Priyadarshini Rout
1mo
public static void main(String[] args) { String s = "abcd23efg1"; int sum = sumOfDigits(s); System.out.println("Sum of digits: " + sum); // Output: Sum of digits: 6 } public static int sumOfDigits(Str...read more
Help your peers!
Select
Add answer anonymously...

TCS Automation Test Engineer interview questions & answers

An Automation Test Engineer was asked 1mo agoQ. What is Encapsulation?
An Automation Test Engineer was asked 2mo agoQ. What is the difference between git pull and git merge?
An Automation Test Engineer was asked 2mo agoQ. Given an input string like 'aaabbbcccdddaa', how would you compress it to an out...read more

Popular interview questions of Automation Test Engineer

An Automation Test Engineer was asked 1mo agoQ1. What is Encapsulation?
An Automation Test Engineer was asked 2mo agoQ2. What is the difference between git pull and git merge?
An Automation Test Engineer was asked 2mo agoQ3. Given an input string like 'aaabbbcccdddaa', how would you compress it to an out...read more

Top HR questions asked in TCS Automation Test Engineer

An Automation Test Engineer was asked 3mo agoQ1. Why did you choose to apply to this company?
An Automation Test Engineer was asked 3mo agoQ2. What are your expectations for this organization?
An Automation Test Engineer was asked 8mo agoQ3. Why TCS, and what makes you different from other candidates?
TCS Automation Test Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits