2. Consider the following code snippet. What is printed? String ocean = new String("Atlantic Ocean"); System.out.println(ocean.indexOf('a'));
Mark for Review
(1) Points 12 2 0 11
3 (*) Correct
3. Given the code: String s = new String("abc"); Which of the following statements will change the length of s to the largest length? Mark for Review
(1) Points s.trim() s.replace("a", "aa") s.substring(2) s.toUppercase() None of the above will change the length of s. (*) Correct
4. The following code is an example of a correct initialization statement: char c="c"; Mark for Review
(1) Points True False (*) Correct
5. Consider the following code snippet
String forest = new String("Black"); System.out.println(forest.length()); What is printed? Mark for Review
(1) Points Black 6 Forest 5 (*) 7 Correct
6. Which of the following defines a driver 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
7. The following defines a class keyword: Mark for Review
(1) Points Provides the compiler information that identifies outside classes used within the current class. Precedes the name of the class. (*) Defines where this class lives relative to other classes, and provides a level of access control. Correct
8. Eclipse does not provide views to help you navigate a hierarchy of information. True or False? Mark for Review
(1) Points True False (*) Correct
9. The ______________ is the location into which you will store and save your files. Mark for Review
(1) Points Perspective Workspace (*) Editor None of the above Correct
10. In Eclipse, when you run a Java Application, the results may be displayed in the Console View. True or False? Mark for Review
(1) Points True (*) False Correct
Previous 11. What is the purpose of the Eclipse Editor Area and Views? Mark for Review
(1) Points To choose the file system location to delete a file. To modify elements.(*) To navigate a hierarchy of information. (*) Correct
12. You can return to the Eclipse Welcome Page by choosing Welcome from what menu? Mark for Review
(1) Points File Help (*) Edit Close Correct
13. Which of the following statements correctly assigns "3 times 10 to the 4th power" to the variable number? Mark for Review
17. One advantage to using a while loop over a for loop is that a while loop always has a counter. True or false? Mark for Review
(1) Points True False (*) Correct
18. In the code fragment below, the syntax for the for loop's initialization is correct. True or false? public class ForLoop { public static void main (String args[]) { for ((int 1=10) (i dol2) return dol1; else return dol2;} All of the above Correct
43. Which of the following could be a reason to return an object? Mark for Review
(1) Points Because you wish to be able to use that object inside of the method. It has faster performance than returning a primitive type. The method makes changes to the object and you wish to continue to use the updated object outside of the method. (*) None of the above. It is not possible to return an object. Correct
44. Which of the following specifies accessibility to variables, methods, and classes? Mark for Review
47. The following statement compiles and executes. What do you know for certain? tree.grows(numFeet); Mark for Review
(1) Points grows must be the name of a method. (*) numFeet must be an int. tree must be a method. grows must be the name of an instance field. tree must be the name of the class. Correct
48. The return value of a method can only be a primitive type and not an object. True or false? Mark for Review
(1) Points True False (*) Correct
49. Which of the following creates a method that compiles with no errors in the class? Mark for Review
(1) Points
(*)
All of the above. None of the above. Incorrect. Refer to Section 7 Lesson 1. 50. If the return type from a method is boolean then 2.5 is a valid return value. True or false? Mark for Review
Thank you for interesting in our services. We are a non-profit group that run this website to share documents. We need your help to maintenance this website.