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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!