Important Notice:

Practice-It will be discontinued as of November 1st, 2024. After this date, the website will remain online for a transitional period, but login will be restricted to University of Washington NetID authentication. This marks the next phase towards the platform's full retirement. Thank you for your use and support of the application over the years.

If you are looking for an alternative, a similar tool, CodeStepByStep, was developed independently by the original author of Practice-It, and is available at codestepbystep.com**

logo Practice-It logo

BJP5 Self-Check 1.12: DoubleSlash

Language/Type: Java basics escape sequences mystery println
Author: Marty Stepp (on 2019/09/19)

What is the output from the following Java program? (Assume that a tab is expanded into eight spaces.)

public class Letter {
    public static void main(String[] args) {
        System.out.println("Dear \"DoubleSlash\" magazine,");
        System.out.println();
        System.out.println("\tYour publication confuses me. Is it");
        System.out.println("a \\\\ slash or a //// slash?");
        System.out.println("\nSincerely,");
        System.out.println("Susan \"Suzy\" Smith");
    }
}

(NOTE ABOUT SPACING: Many students fail this problem by not understanding how the \t character works, causing them to have the wrong number of spaces. A tab inserts multiple spaces until the total number of characters on the current line so far is a multiple of 8. So for example, in the string "hi\thello\tgoodbye\tbeautiful\thi", the first \t becomes 6 spaces (because "hi" is 2 characters, so it takes 6 more to get to 8), the second \t is 3 spaces (because "hello" is 5 characters wide, so it takes 3 more characters to get to 8), the third is 1 (because "goodbye" is 7 characters), and the fourth \t is 7 spaces (because "beautiful" is 9 characters, so it takes 7 more to get to 16, which is the next multiple of 8).

output

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.