Question

what will be printed? String s = "Donal J. Trump"; boolean b = ture; for (int...

what will be printed?

String s = "Donal J. Trump";

boolean b = ture;

for (int i = 0; i < s.length(); i++){

if (b) {

System.out.print(s.charAt(i));

}

if (s.charAt(i) == ' ') {

b = true;

}else {

b = false;

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

DJT

Add a comment
Know the answer?
Add Answer to:
what will be printed? String s = "Donal J. Trump"; boolean b = ture; for (int...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 10. What prints when the following code is executed? public static void main (String args) "Cattywampus"; for (...

    10. What prints when the following code is executed? public static void main (String args) "Cattywampus"; for (int i-s.length )-1 i> 0 i-2) if (s.charAt (i)a') System.out.print(""); ] else if (s.charAt (i)'t') System.out.print (s.charAt (i-2)) i+ti else System. out. print (s . charAt (İ) ) ; if (i<2) System.out.print ("y"); System.out.println () 10. What prints when the following code is executed? public static void main (String args) "Cattywampus"; for (int i-s.length )-1 i> 0 i-2) if (s.charAt (i)a') System.out.print(""); ]...

  • Show the Activation Stack for “ZEROREZ” boolean isPal(String s) { if(s.length() == 0 || s.length() ==...

    Show the Activation Stack for “ZEROREZ” boolean isPal(String s) { if(s.length() == 0 || s.length() == 1) // if length =0 OR 1 then it is return true; if(s.charAt(0) == s.charAt(s.length()-1)) // check first and last char of String: // if same then do same for substring // for substring and carry on this // remove first and last char. return isPal(s.substring(1, s.length()-1)); // if its not the case than string is not. return false; }

  • 10. What prints when the following code is executed? public static void main (String args) "Cattywampus";...

    10. What prints when the following code is executed? public static void main (String args) "Cattywampus"; for (int i-s.length )-1 i> 0 i-2) if (s.charAt (i)a') System.out.print(""); ] else if (s.charAt (i)'t') System.out.print (s.charAt (i-2)) i+ti else System. out. print (s . charAt (İ) ) ; if (i<2) System.out.print ("y"); System.out.println ()

  • JAVA 5) What is the output of the following code? int a = 70; boolean b...

    JAVA 5) What is the output of the following code? int a = 70; boolean b = false; if(a >= 70) { System.out.print(1); if(b==true) { System.out.print(2); } } else { System.out.print(3); if(b==false) { System.out.print(4); } } System.out.print(5); 6) What is the output of the code above using these initial values? int a = 43; boolean b = false; 7) The following method is SYNTACTICALLY correct (meaning it will compile). True or false? public boolean method() { int value = 5;...

  • Please fix my code so I can get this output: Enter the first 12-digit of an...

    Please fix my code so I can get this output: Enter the first 12-digit of an ISBN number as a string: 978013213080 The ISBN number is 9780132130806 This was my output: import java.util.Scanner; public class Isbn { private static int getChecksum(String s) { // Calculate checksum int sum = 0; for (int i = 0; i < s.length(); i++) if (i % 2 == 0) sum += (s.charAt(i) - '0') * 3; else sum += s.charAt(i) - '0'; return 10...

  • Consider the interface Predicate defined as follows. interface Predicate { boolean eval(int j); } Recall that...

    Consider the interface Predicate defined as follows. interface Predicate { boolean eval(int j); } Recall that you can check if an integer “i” is even by using the expression “i%2 == 0”. Write a class IsEven that determines whether a number is even: class IsEven implements Predicate { public boolean eval(int j) { } } For example, the following code Predicate p = new IsEven(); if ( p.eval(2)) { System.out.println("2 is even"); } if (! p.eval(3)) { System.out.println("3 is not...

  • What is printed by running the following code? public static void main(String[] args) { int[] nums...

    What is printed by running the following code? public static void main(String[] args) { int[] nums = {2, 3, 4}; int n = 5; changeMe1(n, nums); System.out.print( n ); System.out.print(nums[0]); changeMe2(n, nums); System.out.print( n ); System.out.print(nums[0]); } public static void changeMe1(int number, int[] list) { number++; list[0]++; } public static void changeMe2(int number, int[] list) { number = 9; list = new int[1]; list[0] = 99; }

  • Background An anagram is a word phrase, or name formed by rearranging the letters of another,...

    Background An anagram is a word phrase, or name formed by rearranging the letters of another, such as the word "cinema", formed from 'iceman". Problem Statement Given two strings s and t, write a function to determine ift is an anagram of S. A sample main function is provided so that you may test your code on sample inputs. Inputs can be provided in the box below your code, please format your input as follows: Example input nose soen Requirements...

  • Java 1. Can you explain it how it will be printed step by step? Thanks!! What...

    Java 1. Can you explain it how it will be printed step by step? Thanks!! What is printed by the following? for (int i=1; i<4; i++) { for (char c=’a’; c<=’c’; c++) { if (i%2==0) { i++; System.out.println(i + " " + c); } else { c++; System.out.println(c + " " + i); } } } 2. Is there a compiler error in this code? If so, what is it? If not, what’s printed? Is there a compiler error in...

  • Question 11 (3 points) What does the following recursive method determine? public boolean question 16(int[]a, int[]...

    Question 11 (3 points) What does the following recursive method determine? public boolean question 16(int[]a, int[] b. intj) { if (j == 2.length) return false; else if ( == b.length) return true; else return question 16(2, b.j+1): 3 returns true if b contains less elements than a, false otherwise returns true if b contains more elements than a, false otherwise returns true if a and bare equal in size, false otherwise returns true if a's element value is larger than...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT