Test: JF Java Fundamentals Final Exam

September 17, 2022 | Author: Anonymous | Category: N/A
Share Embed Donate


Short Description

Download Test: JF Java Fundamentals Final Exam...

Description

 

Test: JF Java Fundamentals Final Exam Section 4 (Answer all questions in this section)

1. Given the code below, which of the following calls are valid? String s = new String("abc");

Mark for Review

(1) Points s.toUpperCase()(*) s.substring(2)(*)

s.trim()(*) s.replace('a', 'A')(*) s.setCharAt(1,'A') Incorrect.  Refer to Section 4 Lesson 4.

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

(1) Points double number=3e4; (*) double number=3(e4); double number=3*10^4; double number=3*10e4; Correct

14. Which line of code does not assign 3.5 to the variable x? Mark for Review

(1) Points x=7.0/2.0; x=3.5; double x=3.5 3.5=x; (*) Correct

15. Which of the following is the name of a Java primitive data type? Mark for Review

(1) Points Rectangle String int (*)

 

Object Correct

Previous Section 5 (Answer all questions in this section)

16. Which of the following are types of loops in Java? Mark for Review

(1) Points while(*) do-while(*) for(*) if/else Correct

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

(1) Points Overload constructors Access modifiers (*) Parameters Methods Correct

 

45. What value will be returned when the setValue method is called?

Mark for Review

(1) Points 38 35 36 37 (*) Correct

Previous 46. Which of the following creates a Object from the Animal class listed below?

Mark for Review

(1) Points Animal dog=new Animal(50); Animal dog=new Animal();

 

Animal dog=Animal(50,30); Animal dog=new Animal(50,30); (*) Correct

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

(1) Points True False (*) Correct

Previous

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF