Computer Science › Evaluating String Expressions
What is the output of the following code?
System.out.println((2*2) + " foo " + (3-1) + new Integer(5) + "3-2");
Consider the code below:
String s = "Logic!";
String s2 = "";
for(int i = 0; i < s.length(); i++) {
if(i != 0) {
s2 += " ";
}
s2 += s;
}
What is the value of s2
at the end of the code's execution?
Suppose you have the following lines of code:
Object integerObj = new Integer(2);
System.out.println((String) integerObj);
What will be the output resulting from running the lines of code?
What is the best way to print out a String variable into a sentence in Swift (iOS)?
string str = "Hello"
char newvar = str\[4\];
What is the value of newvar?
What is the output of the following code?
System.out.println( (1+2) + (3-1) + new Integer(5));
String s = "abcdefghijklmnop";
String s2 = "";
for(int i = 0; i < s.length(); i += 2) {
s2 += s.charAt(i+1);
s2 += s.charAt(i);
}
What is the value of s2
at the end of the code above?
Which of the following will cause the Java compiler to throw an error?
Consider the following code:
What is the output of the method call mystery("Green eggs and ham")?