Java Code


What is wrong with this pseudocode?

try {

   // open some resource

} catch (Exception e) {
   // handle exception
} finally {
   // close the resource

2. Which of the following statements is false?

If a String is not explicitly assigned a value, it will be null.

Strings are immutable.

The static parser methods in the String class can convert strings to other variable types.

Combining strings with + is less computationally efficient than doing so using StringBuffer‘s append() method.

3. Which of the following statements about exceptions in Java is true?

An exception stack trace provides important diagnostic information such as memory consumption

class may only have one catch block.

Variables declared within the try block are accessible from within catch.

A method does not have to declare that it may throw an unchecked exception.

4. What problem(s) will result when this code, which compiles successfully, is executed?

int a = 16;

int b = 14;

boolean c = true;

boolean d = false;

if (c && !d) {

String result = “There are ” + a + b + ” days in September.”;

System.out.println(result.substring(result.length() – result.length()));


A. The code within the if block will never execute.

B. The message in result will show the wrong number of days in September because a and b are concatenated as strings rather than added mathematically.

C. The substring() method could cause an exception.

5. Which statement about the following code is false?

String string1 = “Java”;

String string2 = “JAVA”;

String string3 = “jAvA”;

You could test whether all three strings have the same value by evaluating this expression:

string1.equals(string2) && string2.equals(string3);

Though the strings look different to us, Java considers them equal because of their characters.

Comparing any two of them to one another using equalsIgnoreCase() will return true.

Calling trim() on all three would have no discernible effect.

Do you need help with this assignment or any other? We got you! Place your order and leave the rest to our experts.

Quality Guaranteed

Any Deadline

No Plagiarism