1 . The String methods equals and compareTo perform similar functions and differ in their return type. True or false?
Mark for Review (1) Points
True (*)
False
Correct
2 . Consider the following code snippet.
What is printed?
Mark for Review (1) Points
88888 (*)
88888888
1010778
101077810109
ArrayIndexOutofBoundsException is thrown
Incorrect. Refer to Section 4 Lesson 4.
3 . What is printed by the following code segment?
Mark for Review (1) Points
alligator (*)
albatross alligator
albatross
a1
Correct
4 . Which of the following creates a String named Char?
Mark for Review (1) Points
char string;
String Char; (*)
char Char;
char char;
String char;
Incorrect. Refer to Section 4 Lesson 4.
5 . The following program prints "Not Equal":
True or false?
Mark for Review (1) Points
True (*)
False
Correct
Page 1 of 10
Test: Java Fundamentals Final Exam Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 4 (Answer all questions in this section)
6. Which of the following statements displays 12345?
I. System.out.println( 123 * 100 + 45); II. System.out.println("123" + 45); III. System.out.println( 12 + "345");
Mark for Review (1) Points
All of the above. (*)
I only.
I and II only.
II and III only.
None of the above.
Incorrect. Refer to Section 4 Lesson 3.
7. What are Java's primitive types?
Mark for Review (1) Points
boolean, byte, char, double, float, int, long, and short (*)
boolean, byte, string, thread, int, double, long and short
object, byte, string, char, float, int, long and short
boolean, thread, stringbuffer, char, int, float, long and short
boolean, thread, char, double, float, int, long and short
Correct
8. 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.
Incorrect. Refer to Section 4 Lesson 1.
9. You can return to the Eclipse Welcome Page by choosing Welcome from what menu?
Mark for Review (1) Points
File
Edit
Help (*)
Close
Incorrect. Refer to Section 4 Lesson 1.
10. 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 (*)
Correct
Page 2 of 10
Test: Java Fundamentals Final Exam Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 4 (Answer all questions in this section)
11. A perspective is described as:
Mark for Review (1) Points
A combination of views and editors (*)
A combination of views and windows
A combination of editor tabs
None of the above
Incorrect. Refer to Section 4 Lesson 1.
12. When you open more than one file in Eclipse the system will __________________.
Mark for Review (1) Points
Close the previously opened file.
Use tabs to display all files open. (*)
Put the new file opened in a View area only.
None of the above.
Incorrect. Refer to Section 4 Lesson 1.
13. 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.
Incorrect. Refer to Section 4 Lesson 2.
14. 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.
Incorrect. Refer to Section 4 Lesson 2.
Section 5 (Answer all questions in this section)
15. Why are loops useful?
Mark for Review (1) Points
They save programmers from having to rewrite code.
They allow for repeating code a variable number of times.
They allow for repeating code until a certain argument is met.
All of the above. (*)
Incorrect. Refer to Section 5 Lesson 2.
Page 3 of 10
Test: Java Fundamentals Final Exam Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 (Answer all questions in this section)
16 . A counter used in a for loop cannot be initialized within the For loop header. True or false?
Mark for Review (1) Points
True
False (*)
Incorrect. Refer to Section 5 Lesson 2.
17 . In a for loop the counter is not automatically incremented after each loop iteration. Code must be written to increment the counter. True or false?
Mark for Review (1) Points
True (*)
False
Correct
18 . How would you use the ternary operator to rewrite this if statement? if (gender == "female") System.out.print("Ms.");
Mark for Review
else System.out.print("Mr.");
(1) Points
System.out.print( (gender == "female") ? "Mr." : "Ms." );
System.out.print( (gender == "female") ? "Ms." : "Mr." ); (*)
(gender == "female") ? "Mr." : "Ms." ;
(gender == "female") ? "Ms." : "Mr." ;
Correct
19 . 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
20 . Which of the two diagrams below illustrate the correct syntax for variables used in an if-else statement?
Mark for Review (1) Points
Example A (*)
Example B
Incorrect. Refer to Section 5 Lesson 1.
Page 4 of 10
Test: Java Fundamentals Final Exam Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 (Answer all questions in this section)
21. Suppose you misspell a method name when you call it in your program. Which of the following explains why this gives you an exception?
Mark for Review (1) Points
Because the parameters of the method were not met.
Because the interpreter does not recognize this method since it was never initialized, the correct spelling of the method was initialized.
Because the interpreter tries to read the method but when it finds the method you intended to use it crashes.
This will not give you an exception, it will give you an error when the program is compiled. (*)
Incorrect. Refer to Section 6 Lesson 3.
22. Which of the following sorting algorithms utilizes a "divide and conquer" technique to sort arrays with optimal speed?
Mark for Review (1) Points
Sequential Search
Merge Sort (*)
Selection Sort
Binary Search
All of the above
Incorrect. Refer to Section 6 Lesson 2.
23. Big-O Notation is used in Computer Science to describe the performance of Sorts and Searches on arrays. True or false?
Mark for Review (1) Points
True (*)
False
Incorrect. Refer to Section 6 Lesson 2.
24. Why might a sequential search be inefficient?
Mark for Review (1) Points
It utilizes the "divide and conquer" method, which makes the algorithm more error prone.
It requires incrementing through the entire array in the worst case, which is inefficient on large data sets. (*)
It involves looping through the array multiple times before finding the value, which is inefficient on large data sets.
It is never inefficient.
Incorrect. Refer to Section 6 Lesson 2.
25. Selection sort is a sorting algorithm that involves finding the minimum value in the list, swapping it with the value in the first position, and repeating these steps for the remainder of the list. True or false?
Mark for Review (1) Points
True (*)
False
Correct
Page 5 of 10
Test: Java Fundamentals Final Exam Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 (Answer all questions in this section)
26 . Which of the following declares and initializes a one dimensional array named words of size 3 so that all entries can be Strings?
Mark for Review (1) Points
String strings=new String[3];
String[] word={"Over","the","mountain"}; (*)
String[] word=new String[3];
String[] words={"Oracle","Academy"}];
Incorrect. Refer to Section 6 Lesson 1.
27 . The following segment of code prints all five of the command line arguments entered into this program. True or false?
Mark for Review
(1) Points
True
False (*)
Correct
28 . The following creates a reference in memory named q that can refer to six different integers via an index. True or false?
int[] q = new int[8];
Mark for Review (1) Points
True
False (*)
Incorrect. Refer to Section 6 Lesson 1.
29 . The following creates a reference in memory named q that can refer to eight different doubles via an index. True or false?
double[] q = new double[8];
Mark for Review (1) Points
True (*)
False
Correct
Section 7 (Answer all questions in this section)
30 . Forward thinking helps when creating linear recursive methods. True or false?
Mark for Review (1) Points
True
False (*)
Correct
Page 6 of 10
Test: Java Fundamentals Final Exam
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7 (Answer all questions in this section)
31. A static variable is always publicly available. True or false?
Mark for Review (1) Points
True
False (*)
Correct
32. There is only one copy a static class variable in the JVM. True or false?
Mark for Review (1) Points
True (*)
False
Correct
33. The following statement compiles and executes. What do you know for certain?
tree.grows(numFeet);
Mark for Review (1) Points
numFeet must be an int.
tree must be the name of the class.
grows must be the name of an instance field.
grows must be the name of a method. (*)
tree must be a method.
Incorrect. Refer to Section 7 Lesson 1.
34. A constructor is used to create objects. True or false?
Mark for Review (1) Points
True (*)
False
Incorrect. Refer to Section 7 Lesson 1.
35. The basic unit of encapsulation in Java is the primitive data type. True or false?
Mark for Review (1) Points
True
False (*)
Correct
Page 7 of 10
Test: Java Fundamentals Final Exam Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7 (Answer all questions in this section)
36 . Java's garbage collection is when all references to an object are gone, the memory used by the object is automatically reclaimed. True or false?
Mark for Review (1) Points
True (*)
False
Correct
37 . What value will return for j when the setValue method is called?
Mark for Review (1) Points
31
32
10
11 (*)
Incorrect. Refer to Section 7 Lesson 1.
38 . Identify the driver class that correctly initializes employees Jane and Brandon. The Employee class is below.
Mark for Review
public class Employee { private String name; private int age; private double salary; public Employee(String n, int a, double s) { name = n; age = a; salary = s; } //methods for this class would go here }
(1) Points
public class driver_class { public static void main(String[] args) { Employee Jane = new Employee("Jane", 48, 35.00); Employee Brandon = new Employee("Brandon", 36, 20.00); } } (*)
public class driver_class { public static void main(String[] args) { Employee("Jane", 48, 35.00); Employee("Brandon", 36, 20.00); } }
public class driver_class { public Employee{ Jane = new Employee("Jane", 48, 35.00); Brandon = new Employee("Brandon", 36, 20.00); } }
public class Employee { public class driver-class{ Employee Jane = new Employee(); Employee Brandon = new Employee(); } }
Incorrect. Refer to Section 7 Lesson 1.
39 . Which of the following can be used as a parameter?
Mark for Review (1) Points
(Choose all correct answers)
Integers (*)
Strings (*)
Constructors
Arrays (*)
Objects (*)
Incorrect. Refer to Section 7 Lesson 2.
40 . Which of the following correctly defines overloading?
Mark for Review (1) Points
Having more than one constructor with the same name but different arguments. (*)
Having more than one constructor with different names and the same arguments.
A variable argument method that returns an array.
A type of access specifier that only allows access from inside the same class.
Incorrect. Refer to Section 7 Lesson 2.
Page 8 of 10
Test: Java Fundamentals Final Exam Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7 (Answer all questions in this section)
41 . Which of the following is the definition of a constructor?
Mark for Review (1) Points
A keyword that specifies accessibility of code.
A special method that is used to assign initial values to instance variables in a class. (*)
A way to call a method with a variable number of arguments using an elipse.
A variable in a method declaration that gets passed into the method.
Incorrect. Refer to Section 7 Lesson 2.
42 . Identify the error(s) in the class below. Choose all that apply.
Mark for Review (1) Points
(Choose all correct answers)
No method named min is defined. (*)
Two methods cannot have the same name.
The parameters must be the same for all methods with the same name.
Private cannot be used as an access modifier.
Final cannot be used as an access modifier.
Incorrect. Refer to Section 7 Lesson 2.
43 . Which segment of code represents a correct way to call a variable argument method counter that takes in integers as its variable argument parameter?
Mark for Review (1) Points
counter(String a, int b);
counter(int[] numbers);
counter(1, 5, 8, 17, 11000005); (*)
counter("one","two",String[] nums);
Incorrect. Refer to Section 7 Lesson 2.
44 . Which of the following show the correct UML representation of the super class Planet and its subclass Earth?
Mark for Review (1) Points
(*)
None of the above.
Incorrect. Refer to Section 7 Lesson 4.
45 . Which of the following correctly describes an "is-a" relationship?
Mark for Review (1) Points
A helpful term used to conceptualize the relationships among nodes or leaves in an inheritance hierarchy. (*)
A programming philosophy that promotes simpler, more efficient coding by using exiting code for new applications.
It restricts access to a specified segment of code.
A programming philosophy that promotes protecting data and hiding implementation in order to preserve the integrity of data and methods.
Incorrect. Refer to Section 7 Lesson 4.
Page 9 of 10
Test: Java Fundamentals Final Exam
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7 (Answer all questions in this section)
46 . Why is it not possible to extend more than one class at a time in an inheritance hierarchy chain?
Mark for Review (1) Points
It is not necessary considering all public content is passed from super class to subclass and further to their subclass and that subclass' subclass and so on. (*)
Because the computer cannot handle code that complex.
To prevent confusion for the programmer.
It is possible to extend more than one class at a time.
Incorrect. Refer to Section 7 Lesson 4.
47 . Where should the constructor for a superclass be called?
Mark for Review (1) Points
Anywhere inside the subclass.
Inside the main method of the subclass.
The last line in the constructor of the subclass.
The first line of the constructor in the subclass. (*)
The super constructor does not need to be called inside the subclass.
Incorrect. Refer to Section 7 Lesson 4.
48 . If we override the toString() method with the code below, what would be the result of printing?
Mark for Review (1) Points
It would print the array one element at a time. The console screen would display: 0 18 215 64 11 42
It would print the string returned from the method. The console screen would display: [0,18,215,64,11,42,] (*)
It would print the array backwards. The console screen would display:
42 11 64 215 18 0
It would print the string returned from the method. The console screen would display: {0, 18, 215, 64, 11, 42}
Incorrect. Refer to Section 7 Lesson 5.
49 . Which of the following are true about abstract methods?
Mark for Review (1) Points
(Choose all correct answers)
They cannot have a method body. (*)
They must be overridden in a non-abstract subclass. (*)
They must be declared in an abstract class. (*)
They may contain implementation.
They must be overloaded.
Incorrect. Refer to Section 7 Lesson 5.
50 . Abstract classes can be instantiated. True or false?
Mark for Review (1) Points
True
False (*)

Tidak ada komentar:
Posting Komentar