Format Picture String s = "With more than 50 undergraduate majors!"; a. System.out.println(s.substring(0, 4): b. System.out.println(s.substring(6)); c. System.out.println(s.indexOf("a")); d. System.out.println(s.indexOf ("e")); e. System.out.println(s.toUpperCase(): f. System.out.println(s.length(); g. System.out.println(s.toLowerCase()); h. System.out.println(s.replace("day", "bye")); i. System.out.println(s.substring(5, 9)); j. System.out.println(s.charAt(9)); Shadow time Reflection lude all Glow • Soft Edges writing, or • 3-D Format a. • 3-D Rotation Question b. Artistic Effects htegrity. ons left this cycle c. enews on 4/24/20 d. e. f. g. h. i. j. 2 of 6 38 words English (United States) Focus 100% Engineering Assignment: 19,535 APR 219 13 6. tv •..
Format Picture String s = "With more than 50 undergraduate majors!"; a. System.out.println(s.substring(0, 4): b. System.out.println(s.substring(6)); c. System.out.println(s.indexOf("a")); d. System.out.println(s.indexOf ("e")); e. System.out.println(s.toUpperCase(): f. System.out.println(s.length(); g. System.out.println(s.toLowerCase()); h. System.out.println(s.replace("day", "bye")); i. System.out.println(s.substring(5, 9)); j. System.out.println(s.charAt(9)); Shadow time Reflection lude all Glow • Soft Edges writing, or • 3-D Format a. • 3-D Rotation Question b. Artistic Effects htegrity. ons left this cycle c. enews on 4/24/20 d. e. f. g. h. i. j. 2 of 6 38 words English (United States) Focus 100% Engineering Assignment: 19,535 APR 219 13 6. tv •..
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
What would this print
Expert Solution
Step 1: Outputs
Answer for a.
- Java String is indexed from 0, 1, 2, and so on.
- The function “substring(0,4)” returns the sub-string for the specified index range which is from “0” to “4-1=3”.
- Therefore, the output for the statement “a” is “With”.
Answer for b.
- The function “substring(6)" returns the new string for the index range starting from “6” to the end of the string.
- Therefore, the output for the statement “b” is “ore than 50 undergraduate majors!”.
Answer for c.
- The function “indexOf("a")” returns the index of the first occurrence of the character “a”.
- Therefore, the output for the statement “c” is “12”.
Answer for d.
- The function “indexOf("e")” returns the index of the first occurrence of the character “e”.
- Therefore, the output for the statement “d” is “8”.
Answer for e.
- The function “toUpperCase()” returns the string with all the characters in uppercase letter.
- Therefore, the output for the statement “e” is “WITH MORE THAN 50 UNDERGRADUATE MAJORS!”.
Answer for f.
- The function “length()” returns the number of characters in the string including white spaces and special character.
- Therefore, the output for the statement “f” is “39”.
Answer for g.
- The function “toLowerCase()”returns the string with all the characters in lowercase letter.
- Therefore, the output for the statement “g” is “with more than 50 undergraduate majors!”.
Answer for h.
- The function “replace("day","bye")” replaces the word “day” with the word “bye” in the string.
- But the string does not contain the word “day”. Hence the string without any replacement is returned.
- Therefore, the output for the statement “h” is “With more than 50 undergraduate majors!”.
Answer for i.
- Java String is indexed from 0, 1, 2, and so on.
- The function “substring(5,9)” returns the sub-string for the specified index range which is from “5” to “9-1=8”.
- Therefore, the output for the statement “i” is “more”.
Answer for j.
- The function “charAt(9)” returns the character at the given index “9”. In the given string, there is a whitespace character for the specified index “9”.
Therefore, the output for the statement “j” is “ ”(whitespace).
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education