
Java Class Assessment 4
Quiz by Sunil Kumar V
Tag the questions with any skills you have. Your dashboard will track each student's mastery of each skill.
Given:
1. public class TestString1 {
2. public static void main(String[] args){
3. String str = "420";
4. str += 42;
5. System.out.print(str);
6. }
7. }
What is the output?
Given:
11. StringBuilder sb1 = new StringBuilder("123");
23. String s1 = "123";
24. // insert code here
25. System.out.println(sb1 + "" + s1);
Which code fragment,inserted at line 24, outputs"123abc 123abc"?
Given:
1. public class KungFu {
2. public static void main(String[] args){
3. Integer x = 400;
4. Integer y = x; 5.x++;
6. StringBuilder sb1 = new StringBuilder("123");
7. StringBuilder sb2 = sb1;
8. sb1.append("5");
9. System.out.println((x==y) + "" + (sb1==sb2));
10. }
11. }
What is the result?
String s1 = new String("info");
s1.concat("soft");
s1.concat("systems");
String s2 = s1.concat("solutions");
Find the total number of objects created?
String s1 = "spring";
String s2 = s1 + "summer";
s1.concat("falls");
s2.concat(s1);
s1+="winter";
System.out.println(s1);
System.out.println(s2);
What is the output?