Question
1.Declare a String variable named oneLetter, and initialize it to a String consisting of the letter A. 2.Given a String variable url, write a String
1.Declare a String variable named oneLetter, and initialize it to a String consisting of the letter A.
2.Given a String variable url, write a String expression consisting of the string "http://" concatenated with url. So, if url contains to "www.ocean.edu", the value of the expression would be "http://www.ocean.edu".
3 .If String variable x contains "5" and String variable y contains "2", what is the result of the following expression?
x + y
4. If int variable x contains 5 and int variable y contains 2, what is the result of the following assignment statement?
String z = "12" + x + y;
5. If int variable x contains 5 and int variable y contains 2, what is the result of the following assignment statement?
String z = "12" + (x + y);
6. After the following code is executed, which of I, II and/or III will evaluate to true?
String s1 = "xyz"; String s2 = s1; String s3 = s2; I. s1.equals(s3) II. s1 == s2 III. s1 == s3
7. What is output from the following code?
String s = "Ocean County College"; String s1 = s.substring(0,7); String s2 = s1.substring(2); String s3 = s2.substring(0,3); System.out.println(s3);
8. Given the following code segment, which of the following is true?
String s1 = new String("Hi There"); String s2 = new String("Hi There"); String s3 = s1; I. (s1 == s2) II. (s1.equals(s2)) III. (s1 == s3) IV. (s2.equals(s3))
9.
What does the following code print?
System.out.println("13" + 5 + 3);
(A) 21 (B) 1353 (C) It will give a run-time error (D) 138 (E) It will give a compile-time error
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started