20
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer. Section 4 (Answer all questions in this section) 1 . The following code is an example of instantiating a String object: String str = String( "Hello" ); True or false? Mark for Review (1) Points True False (*) Correct 2 . The following program prints "Not Equal": True or false? Mark for Review (1) Points True (*) False Correct 3 . Consider the following code snippet. Mark for Review (1) Points

Final Test Iin

Embed Size (px)

DESCRIPTION

final java

Citation preview

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Top of FormSection 4

(Answer all questions in this section)

1. The following code is an example of instantiating a String object:

String str = String( "Hello" );

True or false? Mark for Review(1) Points

True

False (*)

Correct

2. The following program prints "Not Equal":

True or false? Mark for Review(1) Points

True (*)

False

Correct

3. Consider the following code snippet.

What is printed? Mark for Review(1) Points

Cayrbniz

CayrbnizCayrbniz

yr (*)

ay

ArrayIndexOutofBoundsException is thrown

Correct

4. What will the following code segment output?

String s="\\\n\"\n\\\n\"";System.out.println(s);Mark for Review(1) Points

\" \"

""\""\""

\"\" (*)

"\"\""

Correct

5. Given the code

String s1 = "abcdef";String s2 = "abcdef";String s3 = new String(s1);

Which of the following would equate to false? Mark for Review(1) Points

s1 == s2

s1 = s2

s3 == s1 (*)

s1.equals(s2)

s3.equals(s1)

Correct

Bottom of FormSection 4

(Answer all questions in this section)

6. The following defines an import keyword: Mark for Review(1) Points

Defines where this class lives relative to other classes, and provides a level of access control.

Provides the compiler information that identifies outside classes used within the current class. (*)

Precedes the name of the class.

Correct

7. Which of the following defines an object class? Mark for Review(1) Points

Contains a main method and other static methods.

Contains classes that define objects. (*)

Contains a main method, a package, static methods, and classes that define objects.

None of the above.

Correct

8. Which of the following is not a legal name for a variable? Mark for Review(1) Points

2bad (*)

zero

theLastValueButONe

year2000

Correct

9. Which of the following is the name of a Java primitive data type? Mark for Review(1) Points

Object

Rectangle

double (*)

String

Correct

10. A workspace can not have more than one stored projects. True or false? Mark for Review(1) Points

True

False (*)

Correct

Section 4

(Answer all questions in this section)

11. Multiple windows are used when more than one file is open in the edit area. True or False? Mark for Review(1) Points

True

False (*)

Incorrect. Refer to Section 4 Lesson 1.

12. What symbols are required for a compiler to ignore a comment? Mark for Review(1) Points

// (*)

/*

*/

/*/

Correct

13. You need to _______________ Java code to generate a .class file Mark for Review(1) Points

Collect

Compile (*)

Package

Assemble

Correct

14. What is the purpose of the Eclipse Editor Area and Views? Mark for Review(1) Points

(Choose all correct answers)

To modify elements. (*)

To navigate a hierarchy of information. (*)

To choose the file system location to delete a file.

Correct

Section 5

(Answer all questions in this section)

15. switch statements work on all input types including, but not limited to, int, char, and String. True or false? Mark for Review(1) Points

True

False (*)

Correct

Section 5

(Answer all questions in this section)

16. How would you use the ternary operator to rewrite this if statement?

if (gender == "female") System.out.print("Ms.");elseSystem.out.print("Mr."); Mark for Review(1) Points

System.out.print( (gender == "female") ? "Mr." : "Ms." );

System.out.print( (gender == "female") ? "Ms." : "Mr." ); (*)

(gender == "female") ? "Mr." : "Ms." ;

(gender == "female") ? "Ms." : "Mr." ;

Incorrect. Refer to Section 5 Lesson 1.

17. Determine whether this boolean expression evaluates to true or false:

!(36||6