GradePack

    • Home
    • Blog
Skip to content

What is the output of the following code? public class Test…

Posted byAnonymous October 2, 2026October 2, 2026

Questions

Whаt is the оutput оf the fоllowing code? public clаss Test {    public stаtic void main(String[] args) {        String s1 = "118-45-9271";        String s2 = "";        for (int i = 0; i < s1.length; i++) {            if (s1.charAt(i) != '-')                s2 += s1.charAt(i);        }        System.out.println(s2);    }}

Slide30.JPG

Slide27.JPG

Slide28.JPG

Tags: Accounting, Basic, qmb,

Post navigation

Previous Post Previous post:
How many times is the println statement executed?
Next Post Next post:
What is the output of the following code? int i = 0;while (i…

GradePack

  • Privacy Policy
  • Terms of Service
Top