Correctly answer the questions. 4) //Working with Strings import java.util.*; pu
ID: 670232 • Letter: C
Question
Correctly answer the questions.
4) //Working with Strings import java.util.*; public class Strings4 { public static void main(String[] args) String[] st= {"1001 :alice :3.5"," 1002:bob:2.5", "1003:carl:2.7","1004:dave:4.0"; for(int i-0; i System.out.printf "%d %s %.21%n, Integer.parseInt(tokens [O ), tokens[1], Float.parseFloat(tokens[2])); )//end of mainO )/lend of class In the above program, what would best replace //? a. String[] tokens -st[i].split(""); b. String[] tokens -st[i].split("*"); c. String[] tokens = st[i],split(":"); d. N one of the above 5) //Working with Strings import java.util.*; public class Strings5 { public static void main(String[] args) String book = "Java How to program 10th ed, Deitel&Deitel;"; String author- "deitel"; boolean bval IKcode> System.out.printf""%s" is authored by "%s". %b", book, author, bval); //end of main) )/lend of class In the above program, what would best replace //? (bval should evaluate to true.) a. book.equals(author); b. book.contains(author); c. book.equalsIgnoreCase(author); d. book.toLowerCase().contains(author.toLowerCase0);Explanation / Answer
As Question Is Mentioned in Photo I am Posting Only Answers Below
Answers:
1)option c(i.e String[] tokens=st[i].split(":");) //On the given Input based on : symbol(delimiter) the given string is splitted as tokens
2)option d(i.e book.to LowerCase().contains(author.toLowerCase());//The given book name i.e string is first converted into lowercase string followed by searching for the author in the converted lowercase string using contains method and string author as "deitel".