1. What are Java's simple types?

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

2. Which of the following are relational operators in Java? (Choose all correct answers)

< (*)
<= (*)
=
!= (*)
All of the above.

3. What is the output of the following lines of code?
int j=6,k=4,m=12,result;
result=j/m*k;
System.out.println(result);
2
0 (*)
48
24

4. A local variable has precedence over a global variable in a Java method. True or false?

True (*) False

5. What does the following program output?

total cost: + 40
total cost: 48
total cost: 40 (*)
"total cost: " 48
"total cost: " 40

6. What is the result when the following code segment is compiled and executed?

int x = 22, y = 10;
double p = Math.sqrt( ( x + y ) /2);
System.out.println(p);

Syntax error "sqrt(double) in java.lang.Math cannot be applied to int"
4.0 is displayed (*)
2.2 is displayed
5.656854249492381 is displayed
ClassCastException
7. Determine whether this boolean expression evaluates to true or false:

!(3<4&&6>6||6<=6&&7-2==6)
True (*) False
8. In an if-else construct the condition to be evaluated must end with a semi-colon. True or false?

True False (*)

9. Which of the two diagrams below illustrate the general form of a Java program?

Example A

Example B (*)

10. 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?

True (*) False

11. When the For loop condition statement is met the construct is exited. True or false?
True False (*)

12. You can return to the Eclipse Welcome Page by choosing Welcome from what menu?

File
Edit
Help (*)
Close

13. In Eclipse, when you run a Java Application, where may the results display?

Editor Window
Console View (*)
Debug View
Task List
None of the above

14. A combination of views and editors are referred to as _______________.

A workspace
A physical location
A perspective (*)
All of the above

15. What are the Eclipse Editor Area and Views used for?(Choose all correct answers)

To modify elements. (*)
To navigate a hierarchy of information. (*)
To choose the file system location to delete a file.
16. What is the output of the following code segment:

int n = 13;
System.out.print(doNothing(n));
System.out.print(" ", n);
where the code from the function doNothin is:
public double doNothing(int n)
{
n = n + 8;
return (double) 12/n;
}

1.75, 13
0.571, 21
1.75, 21
0.571, 13 (*)

17. Updating the input of a loop allows you to implement the code with the next element rather than repeating the code
always with the same element. True or false?
True (*) False

18. One advantage to using a WHILE loop over a FOR loop is that a WHILE loop always has a counter. True or false?
True False (*)

19. Which of the following could be a reason to use a switch statement in a Java program?

Because it allows the code to be run through until a certain conditional statement is true.
Because it allows the program to run certain segments of code and neglect to run others based on the input given. (*)
Because it terminates the current loop.
Because it allows the user to enter an input in the console screen and prints out a message that the user input was successfully read
in.

20. In Java, an instance field referenced using the this keyword generates a compilation error. True or false?
True False (*)

21. Consider

public class YourClass{ public YourClass(int i){/*code*/} // more code...}

To instantiate YourClass, what would you write?
YourClass y = new YourClass();
YourClass y = new YourClass(3); (*)
YourClass y = YourClass(3);
YourClass y = YourClass();
None of the above.

22. A constructor must have the same name as the class it is declared within. True or false?

True (*) False

23. Which of the following keywords are used to control access to the member of a class?

default
public (*)
class
All of the above.
None of the above.
24. Which of the following creates a method that compiles with no errors in the class?

(*)

All of the above.

None of the above

"\\###BOT_TEXT###quot; \\\\ \ \\ (*) 32. Which of the following declares a one dimensional array named names of size 8 so that all entries can be Strings? String names=new String[8]. int[] scores=new int[14]. What will the following code segment output? String s="\\\ System.println(s). (*) int[] scores=new int[14].25. double marks[5]. counter int[]. The following code creates an Object of type Horse. String[] names=new String[8]. What is printed? Mark for Review (1) Points 88888 (*) 88888888 1010778 . float []averages. (*) String[] name=String[8]. String[] name=new Strings[8]. What operator do you use to call an object's constructor method and create a new object? + new (*) instanceOf 27. (*) 29. Which of the following declares a one dimensional array name scores of type int that can hold 14 values? int scores. What is the output of the following segment of code if the command line arguments are "a b c d e f"? 1 3 5 6 (*) 30. Which of the following statements is not a valid array declaration? int number[]. Consider the following code snippet. True False (*) 26. True or false? Whale a=new Whale().out. int score= new int[14] 28. 31.

Exceptions are caused by a mistake in the code and errors occur for no particular reason and therefore cannot be handled or avoided. 101077810109 ArrayIndexOutofBoundsException is thrown 33. Which of the following would equate to false? s1 == s2 s1 = s2 s3 == s1 (*) s1. Given the code String s1 = "abcdef". 35. fee= ( balance < 500) ? 10 : 0. (*) fee = ( balance >= 5) ? 0 : 10. Suppose you misspell a method name when you call it in your program. Choose the best response to this statement: An error can be handled by throwing it and catching it just like an exception. 38.equals(s1) 34. String s3 = new String(s1). If an exception is thrown by a method. 36. False. The catch can be in the method that threw the exception or in any other method that called the method that threw the exception. 37. False. String s2 = "abcdef". else fee = 0. where can the catch for the exception be? There does not need to be a catch in this situation. fee = ( balance < 500) ? 0 : 10. Which of the following explains why this gives you an exception? . To make the user interface harder to navigate. Errors and exceptions are the same objects and are interchangeable. (* True. fee = ( balance > 5) ? 10 : 0. Which of the following could be a reason to throw an exception? To eliminate exceptions from disrupting your program.equals(s2) s3. (*) You have a fatal error in your program. True. You have encountered a Stack Overflow Error. The catch must be in the method that threw the exception. Although errors may be more severe than exceptions they can still be handled in code the same way exceptions are. (*) The catch must be immediately after the throw. How would you use the ternary operator to rewrite this if statement? if (balance < 500) fee = 10. fee = ( balance >= 500) ? 10 : 0. An error is much more severe than an exception and cannot be dealt with adequately in a program.

needOil(). the correct spelling of the method was initialized. Static classes are designed as thread safe class instances. Because the interpreter does not recognize this method since it was never initialized. This will not give you an exception. public) {return a/b. Public static variables can't have their value reset by other classes. public int b) {return a/b. It is possible for a subclass to be a superclass. They are used to organize the relationship between a superclass and its subclasses. They restrict a superclass to only have one subclass.} 46.} divide(public int a. methods. counter(1. 8. 5. 11000005). Which of the following specifies accessibility to variables. divide(int a. SqueakyRobot. True or false? True False (*) 45. super. 40. and classes? Methods Parameters Overload constructors Access specifiers (*) 47. (*) counter("one". True or false? True False (*) 43.} public divide(int a. True or false? True False (*) 44. int b). int b) {public return a/b. Because the parameters of the method were not met. counter(int[] numbers). Which segment of code represents a correct way to call a variable argument method counter that takes in integers as its variable argument parameter? counter(String a. Because the interpreter tries to read the method but when it finds the method you intended to use it crashes. Choose the correct implementation of a public access modifier for the method divide. Which of the following can be declared final? . int b. Why are hierarchies useful for inheritance? They keep track of where you are in your program. (*) 39. 48."two". True or false? True (*) False 42. They organize constructors and methods in a simplified fashion. int b) {return a/b. (*) 41. Which of the following is the correct way to call an overriden method needOil() of a super class Robot in a subclass SqueakyRobot? Robot.needOil().String[] nums). (*) needOil(Robot). Static methods can write to instance variables. 17.} (*) divide(int a.needOil(SqueakyRobot). it will give you an error when the program is compiled.

50. Classes Methods Local variables Method parameters All of the above (*) 49.e. Joe wants to create a program that will store his textbooks in one group of books. (*) This is not possible. An asterisk (*) indicates a correct answer. and question scores below. String str = String( "Hello" ). Review (1) Points True or false? True False (*) Correct 2The following program prints "Not Equal": Mark for . The concept that a variable or reference can hold multiple types of objects. MathBook is a book). A class that cannot be initiated. Which of the following would be most beneficial for this scenario? Joe is a college student who has a tendency to lose his books. Joe must find another way to collect the books. but he wants to make each book type the subject of the book (i. (*) Review your answers. How could he store these different subject books into a single array? By ignoring the subject type and initializing all the book as objects of type Book. Replacing them is getting costly. What is Polymorphism? A way of redefining methods with the same return type and parameters. feedback. In an attempt to get organized. A way to create multiple methods with the same name but different parameters. By overriding the methods of Book. Section 4 (Answer all questions in this section) 1The following code is an example of instantiating a String object: Mark for . Using polymorphism. Review (1) Points True or false? True (*) .

Review (1) Points What is printed? Cayrbniz CayrbnizCayrbniz yr (*) ay ArrayIndexOutofBoundsException is thrown Correct 4What will the following code segment output? Mark for . Mark for . String s="\\n###BOT_TEXT###quot;\n\\n###BOT_TEXT###quot;". False Correct 3Consider the following code snippet.out. (1) Points ###BOT_TEXT###quot; ###BOT_TEXT###quot; ""\ "" \ "" \ " \ " (*) " \ " \ " " Correct . Review System.println(s).

a package. and classes that define objects. String s1 = "abcdef". (*) Precedes the name of the class. Provides the compiler information that identifies outside classes used within the current class.equals(s2) s3. Which of the following is not a legal name for a variable? Mark for Review (1) Points 2bad (*) zero . (*) Contains a main method.equals(s1) Correct Section 4 (Answer all questions in this section) 6. Review String s2 = "abcdef". None of the above. Which of the following would equate to false? s1 == s2 s1 = s2 s3 == s1 (*) s1. Contains classes that define objects. Which of the following defines an object class? Mark for Review (1) Points Contains a main method and other static methods. 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. (1) Points String s3 = new String(s1). Correct 8. 5Given the code Mark for . Correct 7. static methods.

What symbols are required for a compiler to ignore a comment? Mark for Review (1) Points // (*) /* */ /*/ Correct . 12. Which of the following is the name of a Java primitive data type? Mark for Review (1) Points Object Rectangle double (*) String Correct 10. True or false? Mark for Review (1) Points True False (*) Correct Section 4 (Answer all questions in this section) 11. theLastValueButONe year2000 Correct 9. Mark for Review True or False? (1) Points True False (*) Incorrect.Multiple windows are used when more than one file is open in the edit area. Refer to Section 4 Lesson 1.A workspace can not have more than one stored projects.

int. (1) Points else System. (*) To choose the file system location to delete a file. System. Correct Section 5 (Answer all questions in this section) 15.out. 13."). True or false? (1) Points True False (*) Correct Section 5 (Answer all questions in this section) 16. (*) (gender == "female") ? "Mr.print( (gender == "female") ? "Ms." ).You need to _______________ Java code to generate a .print( (gender == "female") ? "Mr." ." : "Ms." : "Mr. Mark for Review char. System.out.out. and String." : "Ms. but not limited to. (*) To navigate a hierarchy of information.print("Ms.")." ).What is the purpose of the Eclipse Editor Area and Views? Mark for Review (1) Points (Choose all correct answers) To modify elements.print("Mr.out.class file Mark for Review (1) Points Collect Compile (*) Package Assemble Correct 14.switch statements work on all input types including.How would you use the ternary operator to rewrite this if statement? Mark for Review if (gender == "female") System. .

Println ("i: "+i). Refer to Section 5 Lesson 1. Refer to Section 5 Lesson 2. It continues looping until the condition becomes false. True or Mark for Review false? (1) Points True False (*) Correct 20." .When the for loop condition statement is met the construct is exited. It is a modified while loop that allows the program to run through the loop once before testing the boolean condition. (*) . Refer to Section 5 Lesson 1. 18. All of the above. the syntax for the for loop's initialization is Mark for Review correct.out. (gender == "female") ? "Ms.Determine whether this boolean expression evaluates to true or false: Mark for Review !(3<4&&6>6||6<=6&&7-2==6) (1) Points True (*) False Incorrect.Which of the following is true about a do-while loop? Mark for Review (1) Points It is a post-test loop. True or false? (1) Points public class ForLoop { public static void main (String args[]) { for ((int 1=10) (i<20) (i++))<br> {System.In the code fragment below." : "Mr. } } } True False (*) Incorrect. 19. Incorrect. 17.

out. arguments are "a b c d e f g"? Review (1) Points f e (*) c d This code doesn't compile. Incorrect. System. for(int i = 0. for(int i = 0. System. (*) int total = 0. i total = total+prices[i].out. for(int i = 0. 23What is the output of the following segment of code? Mark for . i total+=prices[i]. int total = 0. for(int i = 1. and then prints the sum to the screen? Review (1) Points int total = 0.println(prices). Correct Section 6 (Answer all questions in this section) 21Which of the following statements add all of the elements of the one dimensional Mark for . System. i total+=prices[i]. Refer to Section 6 Lesson 1. Correct 22What is the output of the following segment of code if the command line Mark for .out. array prices. int total = 0.println(total).println(prices). i total+=prices[i]. Review (1) Points .

Correct 24The following segment of code initializes a 2 dimensional array of primitive data Mark for . There is nothing wrong with this code. It does not compile. (1) Points True (*) False Correct 25What is wrong with this code? Mark for . Review (1) Points It is missing a semicolon.Selection sort is a sorting algorithm that involves finding the minimum value Mark for Review in the list. Correct Section 6 (Answer all questions in this section) 26. and repeating these steps for the remainder of the list. (*) It gives you an out of bounds exception. types. 321123 642 642246 (*) 312213 This code doesn't compile. swapping it with the value in the first position. True or false? Review double[][] a=new double[4][5]. True or false? (1) Points True (*) .

finding the next smallest value and swapping it into the next index and so on until the array is sorted. which makes the algorithm more error prone.Bubble Sort is a sorting algorithm that involves swapping the smallest value Mark for Review into the first index. It is never inefficient. False Correct 27. what is the fastest run-time? Mark for Review (1) Points n n^2 lg(n) (*) n*lg(n) Correct 28. . Correct Section 7 (Answer all questions in this section) 30. It requires incrementing through the entire array in the worst case. which is inefficient on large data sets.Which of the following is the correct way to code a method with a return type Mark for Review an object Automobile? (1) Points Automobile upgrade(String carA){ carA="Turbo". True or false? (1) Points True False (*) Correct 29. (*) It involves looping through the array multiple times before finding the value.Why might a sequential search be inefficient? Mark for Review (1) Points It utilizes the "divide and conquer" method.Of the options below. which is inefficient on large data sets.

setTurbo("yes").} upgrade(Automobile carA) Automobile{ carA. methods.setTurbo("yes"). A special method that is used to assign initial values to instance variables in a class.} None of the above. Correct Section 7 (Answer all questions in this section) 31.} (*) String upgrade(String carA){ carA="Turbo". return carA. Refer to Section 7 Lesson 2. return carA. return carA. and Mark for Review classes? (1) Points Methods Parameters Overload constructors Access modifiers (*) Incorrect. 33. return carA.Which of the following is the definition of a constructor? Mark for Review (1) Points A keyword that specifies accessibility of code.Which of the following specifies accessibility to variables.Which of the following are access modifiers? Mark for Review (1) Points (Choose all correct answers) protected (*) public (*) secured default (no access modifier) (*) private (*) Incorrect.} Automobile upgrade(Automobile carA){ carA. (*) . 32. It is not possible to return an object. Refer to Section 7 Lesson 2.

oak) {//code here }. Tree oak) {//code here }... void bloom. Refer to Section 7 Lesson 2.) public abstract class ClassName{. A way to call a method with a variable number of arguments using an elipse.Identify the correct way to declare an abstract class.} public abstract ClassName(. Mark for Review (1) Points abstract public class ClassName{. Tree pine..} (*) Correct 37. objects cannot be passed as parameters.) public class abstract ClassName(... (*) Correct Section 7 (Answer all questions in this section) 36.What is Polymorphism? Mark for Review (1) Points A way of redefining methods with the same return type and parameters. True or false? Mark for Review (1) Points True .Abstract classes cannot implement interfaces. None of the above. A variable in a method declaration that gets passed into the method. Correct 34. A class that cannot be initiated. Incorrect.. (*) Tree bloom (pine. 35. A way to create multiple methods with the same name but different parameters. The concept that a variable or reference can hold multiple types of objects.Which segment of code correctly defines a method that contains two objects Mark for Review of class Tree as parameters? (1) Points void bloom(Tree pine... Tree oak {//code here }.

an instance field referenced using the this keyword generates a compilation Mark for .Static methods can't change any class variable values at run-time. False (*) Correct 38. True or false? Mark for Review (1) Points True (*) False Correct 40.There is only one copy a static class variable in the JVM. True or false? Mark for . True or Mark for Review false? (1) Points True False (*) Correct Section 7 (Answer all questions in this section) 41In Java. True or false? Review (1) Points True False (*) Correct 42A constructor is used to create objects. error. Review .A linear recursion requires the method to call which direction? Mark for Review (1) Points Forward Backward (*) Both forward and backward None of the above Correct 39.

Review public class Employee { (1) Points private String name. 48. The Mark for . Employee("Brandon". 35. } } public class driver_class { public Employee{ Jane = new Employee("Jane". int a. 35. salary = s. 36. 48. private double salary. } //methods for this class would go here } public class driver_class { public static void main(String[] args) { Employee Jane = new Employee("Jane". Employee class is below. } } .00).00). 48.00). 20. double s) { name = n. } } (*) public class driver_class { public static void main(String[] args) { Employee("Jane". private int age. Employee Brandon = new Employee("Brandon". Brandon = new Employee("Brandon". false? Review (1) Points True (*) False Correct 44Identify the driver class that correctly initializes employees Jane and Brandon. 36.00). 20. True or Mark for . public Employee(String n.00). 36. 35. 20. (1) Points True (*) False Correct 43A constructor must have the same name as the class where it is declared.00). age = a.

Section 7 (Answer all questions in this section) 46. 45Which of the following creates a method that compiles with no errors in the class? Mark for . Employee Brandon = new Employee(). Incorrect. Review (1) Points (*) All of the above. } } Incorrect. None of the above. Refer to Section 7 Lesson 1. (1) Points True False (*) Correct . Refer to Section 7 Lesson 1. public class Employee { public class driver-class{ Employee Jane = new Employee().The following code creates an object of type Horse: Mark for Review Whale a=new Whale().

Any variable passed through inheritance can be changed. but private methods cannot. super. Incorrect.needOil(). A private variable can only be modified by the same class with which it is declared regardless of its inheritance.Which of the following is the correct way to call an overriden method Mark for Review needOil() of a super class Robot in a subclass SqueakyRobot? (1) Points Robot.Which of the following show the correct UML representation of the super Mark for Review class Planet and its subclass Earth? (1) Points (*) .needOil(SqueakyRobot). No. Yes.47. Nothing inherited by the super class can be changed in the subclass.needOil(). Refer to Section 7 Lesson 4. could it be directly accessed or Mark for Review modified by a subclass? Why or why not? (1) Points Yes.If a variable in a superclass is private. SqueakyRobot. (*) needOil(Robot). 49. Correct 48. A subclass inherits full access to all contents of its super class. (*) No.

!=. The six relational operators in Java are: >. Refer to Section 7 Lesson 4. A programming philosophy that promotes simpler. (*) Incorrect. concepts of things with the most general at the top and the most specific at the bottom.=<.>= >. (x && !y) || (!x && y) III. Incorrect. 50. (x || y) && !(x && y) II. Refer to Section 7 Lesson 4. more efficient coding by using exiting code for new applications.!=.!=. (*) double number=6(e5).=. Which of the following expressions will evaluate to true when x and y are boolean variables with opposite values? I.==.=. None of the above.<=.=.What is encapsulation? Mark for Review (1) Points A keyword that allows or restricts access to data and methods.>= >. A structure that categorizes and organizes relationships among ideas.>= (*) >. double number=6*10e5.<=. 1.<. (x || y) && (!x ||!y) I only II only I and III II and III I. Select the statement that declares a number of type double and initializes it to 6 times 10 to the 5th power. Examine the following code: What is the value of variable x? 2 (*) . double number=6e5. A programming philosophy that promotes protecting data and hiding implementation in order to preserve the integrity of data and methods.!.=> 4.<. II. and III (*) 3.<.<. double number=6*10^5. 2.<=.

lang. double p = Math.out. 6 0 -42 2 (*) 8. Which of the following is not a legal name for a variable? 2bad (*) zero theLastValueButONe year2000 7.Println ("i: "+i). What is the result when the following code segment is compiled and executed? int x = 22. result=j-k%3*m. Which of the two diagrams below illustrate the correct syntax for variables used in an if- else statement? Example A (*) Example B 10.out. When importing another package into a class you must import only the package classes that will be called and not the entire package. Syntax error "sqrt(double) in java. where may the results display? Editor Window Console View (*) Debug View Task List None of the above . System.Math cannot be applied to int" 4.sqrt( ( x + y ) /2). True or false? True False (*) 9. 11. Refer to Section 4 Lesson 2. y = 10. when you run a Java Application.656854249492381 is displayed ClassCastException 6.println(result).result.2 is displayed 5.println(p). } } } True False (*) 12. True or false? public class ForLoop { public static void main (String args[]) { for ((int 1=10) (i<20) (i++))< {System.k=8.0 is displayed (*) 2. In the code fragment below. System. the syntax for the for loop's initialization is correct. What is the output of the following lines of code? int j=6. True or false? True False (*) Incorrect.out. In an if-else construct the condition to be evaluated must end with a semi-colon.m=2. In Eclipse.5 6 14 5.2.

13.in). privateint number. Consider that a Scanner has been initialized such that: Scanner in = new Scanner(System. privateString name. Account. 17. True or false? True False (*) 20. Switch statements work on all input types including. return. One advantage to using a WHILE loop over a FOR loop is that a WHILE loop always has a counter. True or false? True False (*) 18. (*) 16. 19. All of the above. char.. Which of the following lines of code reads in the user's input and sets it equal to a new String called input? String input = in. A combination of views and editors are referred to as _______________. (*) String input = in. (*) . The location where you can have one or more stored perspectives. (*) break. but not limited to. The location where all projects are developed and modified. i++){ if(i%2 == 0) //your answer here else k+=3. int.next(). String input = in. What is wrong with the following class declaration? class Account{ . and String. String input = new String in.nextInt(). What should replace the comment "//your answer here" in the code below if the code is meant to take no action when i % 2 is 0 (in other words when i is even)? for(int i = 0. You can return to the Eclipse Welcome Page by choosing Welcome from what menu? File Edit Help (*) Close 15. A workspace is: The physical location onto which you will store and save your files. A workspace A physical location A perspective (*) All of the above 14. k+=1. } Classes cannot include strings.close().. The constructor method has no definition.next(). Classes cannot include mixed data types. i < 10. } continue.

Student{ name="Jane Doe". ThisClass t=new ThisClass(5).i++) for(int j=0. Animal cat=Animal(50. Incorrect. } public class Student private String name.30). Student(){ name="Jane Doe". float gpa=3. } Incorrect.i<2.out. What is the output of the following segment of code? int array[][] = {{1.i<prices. Refer to Section 5 Lesson 2. What is true about the code below: Car car1=new Car().out. Which of the following creates an instance of the class below? ThisClass t=new ThisClass(). 21. private float gpa. Animal cat=new Animal(50. Which of the following statements adds 5 to every element of the one dimensional array prices and then prints it to the screen? for(int i=0. 23. gpa=3.print(2*array[1][1]). A class always has a constructor. The reference car2 points to an exact copy of the Car Object that car1 references. The references car1 and car2 are pointing to two Car Objects in memory. Which of the following creates an object from the Animal class listed below: Animal cat=new Animal(). ThisClass t=new ThisClass(3. System.0.2.j++) System. car2=car1.out. (*) Incorrect.println(prices[i]+5). 28. True or false? True (*) False 22.30). ThisClass t. A constructor must have the same name as the class it is declared within.println(prices[i]+5). True or false? True (*) False Section 6 27. Refer to Section 5 Lesson 2. private float gpa.{3.3}. public class Student { private String name. (*) Animal cat=new Animal(50).There is nothing wrong.} } (*) public class Student { private String name. Student(). Which of the following creates a class named Student with one constructor. Refer to Section 5 Lesson 2. (*) There is a Car object that car2 referenced that is now slated for removal by the garbage collector.1}}.4). 444444 (*) 123321 246642 222222 This code doesn't compile.2. 26.length. There are no more Car objects in memory. for(int i=0.0.i++) System. Car car2=new Car(). There is a Car object that car1 referenced that is now slated for removal by the garbage collector. 25. and 2 instance variables name and gpa? public class Student { private String name. private float gpa. 24. .j<3.

Object array=new Object[5]. What will the following code segment output? String s="\\n###BOT_TEXT###quot;\n\\n###BOT_TEXT###quot;".out. String s. Given the code String s1 = "abcdef". The == operator can be used to compare two String objects. . Refer to Section 6 Lesson 1. for(int i=0. String s3 = new String(s1). Which of the following creates a String reference named s and instantiates it? String s="".i++) System.i++) System.out. (*) s="s". 33. (*) Object[] array=new Object[4]. String[] array=String[4]. Incorrect. Which of the following declares and initializes a two dimensional array that can hold 6 Object reference types? String[] array=new String[6]. (*) String[][] array=String[6]. System.println(prices[i]+5). True or false? True False (*) 34.out. Which of the following declares and initializes a one dimensional array that can hold 5 Object reference types? String[] array=new String[5].i<prices. The result is always true if the two strings are have the exact same characters in each position of the String. Refer to Section 6 Lesson 2. String s=new String("s").for(int i=1. (*) Incorrect.length.length. 30.i<prices. 31. Refer to Section 6 Lesson 1. String s2 = "abcdef". (*) 32. Object array=new Object[6]. Object[][] array=new Object[2][3]. ###BOT_TEXT###quot; ###BOT_TEXT###quot; ""\ "" \ "" \ " \ " (*) " \ " \ " " Incorrect. 29.println(s).println(prices[1]+5).

It means to handle it. (*) = (single equals sign) compares the value of primitive types such as int or char. (*) The catch must be immediately after the throw. True or false? True False (*) Incorrect. (*) 37. (*) == (two equal signs) compares the values of non-primitive objects. True or false? True False (*) Incorrect. Forward thinking helps when creating linear recursive methods. What does it mean to catch an exception? It means you have fixed the error. If an exception is thrown by a method. Section 7 39. 38. True or false? True False (*) 36. Refer to Section 7 Lesson 2.equals() compares the value of non-primitive objects. The catch must be in the method that threw the exception. Refer to Section 7 Lesson 2. where can the catch for the exception be? There does not need to be a catch in this situation. Everything that follows the semicolon is interpreted as code outside of the loop. a line that does nothing. It means to throw it. Which of the following correctly matches the symbol with its function? == (two equal signs) compares values of primitive types such as int or char.equals(s2) s3. Which case handles the last recursive call? The base case (*) The primary case The secondary case The convergence case The recursive case Incorrect. 40. == (two equal signs) compares the memory location of non-primitive objects. 41. 42. (*) It means there was never an exception in your code. It is possible to return an object in a method. Refer to Section 7 Lesson 2. A logic error occurs if an unintentional semicolon is placed at the end of a loop initiation because the interpreter reads this as the only line inside the loop. . The catch can be in the method that threw the exception or in any other method that called the method that threw the exception.equals(s1) 35. Static methods can't change any class variable values at run-time.Which of the following would equate to false? s1 == s2 s1 = s2 s3 == s1 (*) s1. True or false? True (*) False .

(*) Declare the child class as abstract.} (*) divide(int a. int b) {public return a/b. If it is possible to inherit from an abstract class.} public class Applet extends Battlefield{. data.43. because polymorphism allows this since Dog is a subclass of HousePet. more efficient coding by using exiting code for new applications. what must you do to prevent a compiler error from occurring? It is not possible to inherit from an abstract class. public int b) {return a/b. What is true about the Object class? It is the highest superclass. There is no way to tell without seeing the methods for Dog and the methods for HousePet.} public divide(int a. (*) Its methods can be overloaded in subclasses...} (*) public Applet Battlefield{. divide(int a. because ref must be declared either a HousePet or a Dog. Yes. (*) A programming philosophy that promotes simpler. (*) No.. (*) It extends other classes. 47. (*) 48. The six relational operators in Java are: Mark for Review (1) Points . Override all abstract methods from the parent class.} public class Battlefield(Applet){. Create all new methods and variables different from the parent class. Which segment of code represents a correct way to define a variable argument method? String easyArray(String... True or false? True (*) False 50. It restricts access to a specified segment of code. 49..String elems) {//code} String. (int elems) {//code} 44. Which of the following correctly describes an Is-A relationship? A helpful term used to conceptualize the relationships among nodes or leaves in an inheritance hierarchy.... Maybe. public) {return a/b.. An access modifier is a keyword that allows subclasses to access methods. easyArray(String elems) {//code} Integer easyArray. Which of the following demonstrates the correct way to create an applet Battlefield? public class Battlefield extends Applet{. because it is an abstract class.. int b) {return a/b.} divide(public int a. Its methods can be overridden in subclasses. Would this code be correct if a Dog is a HousePet? Why or Why not? HousePet Scooby = new Dog()... elems) {//code} (*) String easyArray(.} Section 4 (Answer all questions in this section) 1. int b. A programming philosophy that promotes protecting data and hiding implementation in order to preserve the integrity of data and methods... Choose the correct implementation of a public access modifier for the method divide.} 45. Yes. but not both.. (*) 46. and constructors from their parent class.

Refer to Section 4 Lesson 3.>= >.=.<=.=<.!=.!=.<=. The three logic operators in Java are: Mark for Review (1) Points &&.|.=> Correct 2.=.=.==.<=. What does the following program output? Mark for Review (1) Points total cost: + 40 total cost: 48 total cost: 40 (*) "total cost: " 48 "total cost: " 40 Incorrect.<.=.<.>= (*) >.<. .<. 4.!=. ! (*) !=. >.!.!=.= Correct 3. Which line of Java code will assign the square root of 11 to a? Mark for Review (1) Points double a=11^(1/2). ||.= &.>= >.== &&.

(*) Correct 5. double x=(double)i/j. double x=(double)(i/j). double x= double i/j. Mark for Review (1) Points int x=(double)2.54. double x=i/j.sqrt*11. int a=Math. What two values can a boolean variable have? Mark for Review (1) Points Numbers and characters True and false (*) Relational and logic operators Arithmetic and logic operators Integers and floating point types Correct Page 1 of 10 Next Summary Test: Java Fundamentals Final Exam Section 4 (Answer all questions in this section) 6. which line of Java code properly casts one type into another without data loss? int i=3. double a=Math. double y=2.j=4. double a=Math. (*) Correct 7. Which of the following is a legal identifier? Mark for Review (1) Points 7up boolean .sqrt(11).sqrt(11). Given the following declaration.54. double a=sqrt(11).

. grand Total apple (*) Correct 8. 9. Refer to Section 4 Lesson 2. Refer to Section 4 Lesson 2. True or false? Mark for Review (1) Points True False (*) Incorrect. When the For loop condition statement is met the construct is exited. True or false? Mark for Review (1) Points True (*) False Incorrect. In a For loop the counter is not automatically incremented after each loop iteration. Code must be written to increment the counter.

Which of the two diagrams below illustrate the general form of a Java program? Mark for Review (1) Points Example A Example B (*) Correct . 10.

where may the results display? Mark for Review (1) Points Editor Window Console View (*) Debug View Task List . When you open more than one file in Eclipse the system will __________________. Mark for Review (1) Points Close the previously opened file. Refer to Section 4 Lesson 1.Previous Page 2 of 10 Next Summary Test: Java Fundamentals Final Exam Section 4 (Answer all questions in this section) 11. Refer to Section 4 Lesson 1. Use tabs to display all files open. In Eclipse. (*) Put the new file opened in a View area only. 14. 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 (*) Correct 12. Incorrect. Mark for Review (1) Points A workspace A physical location A perspective (*) All of the above Incorrect. A combination of views and editors are referred to as _______________. when you run a Java Application. 13. None of the above.

They allow for repeating code until a certain argument is met. (*) . What are the Eclipse Editor Area and Views used for? Mark for Review (1) Points (Choose all correct answers) To modify elements. Switch statements work on all input types including. and String. int. An asterisk (*) indicates a correct answer. True or false? Mark for Review (1) Points True False (*) Correct 18. Which of the following best describes a WHILE loop? Mark for Review (1) Points A loop that contains a segment of code that is executed before the conditional statement is tested. All of the above. A loop that executes the code at least one time even if the conditional statement is false. (*) A loop that contains a counter in parenthesis with the conditional statement. and question scores below. but not limited to. Correct 17. (*) To navigate a hierarchy of information. None of the above Correct 15. They allow for repeating code a variable number of times. (*) To choose the file system location to delete a file. char. feedback. Correct Previous Page 3 of 10 Next Summary Test: Java Fundamentals Final Exam Review your answers. A loop that is executed repeatedly until the conditional statement is false. Section 5 16. Why are loops useful? Mark for Review (1) Points They save programmers from having to rewrite code.

Account. privateint number.. Correct Previous Page 4 of 10 Next Summary Test: Java Fundamentals Final Exam . The constructor method has no definition. Correct 19. privateString name. Which of the following correctly matches the switch statement keyword to its function? Mark for Review (1) Points (Choose all correct answers) switch: tells the compiler the value to compare the input against default: signals what code to execute if the input does not match any of the cases (*) case: signals what code is executed if the user input matches the specified element (*) if: records the user's input and sends it to the case statements to find a possible match switch: identifies what element will be compared to the element of the case statements to find a possible match (*) Correct 20. } Mark for Review (1) Points Classes cannot include strings. What is wrong with the following class declaration? class Account{ .. Classes cannot include mixed data types. (*) There is nothing wrong.

Review your answers. The constructor method must always have at least one parameter. (*) None of the above. Section 5 21. Incorrect. True or false? Mark for Review (1) Points True (*) False Correct 24. True or false? Mark for Review (1) Points True False (*) Correct 25. The basic unit of encapsulation in Java is the primitive data type. 22. True or false? Mark for Review (1) Points True False (*) Correct 23. A constructor must have the same name as the class it is declared within. an instance field referenced using the this keyword generates a compilation error. In Java. Which of the following may be part of a class definition? Mark for Review (1) Points Instance variables Instance methods Constructors All of the above. True or false? Mark for Review (1) Points True False (*) . and question scores below. Refer to Section 5 Lesson 2. An asterisk (*) indicates a correct answer. feedback.

b) System.i<prices. for(int i=1. True or false? int[] y = new int[5]. c) int total for(int i=1.out. System. Refer to Section 6 Lesson 1.println(prices). and question scores below.i++) System.out. feedback. Incorrect.i total+=prices[i]. The following array declaration is valid. An asterisk (*) indicates a correct answer. True or false? Mark for Review (1) Points True (*) False Correct Section 6 27.i total+=prices[i]. A constructor is used to create objects.out. Mark for Review (1) Points True (*) False Correct 29. Which of the following statements is not a valid array declaration? Mark for Review . Section 5 26. Which of the following statements adds all of the elements of the one dimensional array prices and then prints it to the screen? Mark for Review (1) Points a) for(int i=0. Correct Previous Page 5 of 10 Next Summary Test: Java Fundamentals Final Exam Review your answers. 28. (*) d) int total=0.length.println(prices[i]+1).println(total).

30.3.4.i=i+3) System. float []averages. (*) Incorrect. What is the output of the following segment of code? int num[]={9. Mark for Review (1) Points 9630 963 (*) 987654321 97531 This code doesn't compile. for(int i=0. What is printed? Mark for Review (1) Points 88888 (*) .5.1}. and question scores below. Consider the following code snippet.7. feedback.8. Refer to Section 6 Lesson 1. Correct Previous Page 6 of 10 Next Summary Test: Java Fundamentals Final Exam Review your answers.print(num[i]).6.i<9.(1) Points int number[]. An asterisk (*) indicates a correct answer.2. double marks[5]. counter int[].out. Section 6 31.

Refer to Section 6 Lesson 2. 33. It means to handle it. 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 (*) Incorrect. (*) str1 >= str2 Str1 -= str2. True or false? Mark for Review (1) Points True (*) False Correct 35. The == operator tests if two String references are pointing to the same String object. (*) It means there was never an exception in your code. Refer to Section 6 Lesson 2. Suppose that str1 and str2 are two strings. . Correct 34. Which of the statements or expressions are valid? Mark for Review (1) Points String str3 = str1 .str2. What does it mean to catch an exception? Mark for Review (1) Points It means you have fixed the error. str1 += str2. 32. It means to throw it. 88888888 1010778 101077810109 ArrayIndexOutofBoundsException is thrown Incorrect.

38. True or false? Mark for Review (1) Points True False (*) Incorrect. Correct Previous Page 7 of 10 Next Summary Test: Java Fundamentals Final Exam Review your answers.equals() compares the value of non-primitive objects. Refer to Section 6 Lesson 3. An asterisk (*) indicates a correct answer. . Refer to Section 6 Lesson 3. (*) == (two equal signs) compares the values of non-primitive objects. Which of the following correctly matches the symbol with its function? Mark for Review (1) Points (Choose all correct answers) == (two equal signs) compares values of primitive types such as int or char. . 37. feedback. a line that does nothing. Everything that follows the semicolon is interpreted as code outside of the loop. Section 6 36. A logic error occurs if an unintentional semicolon is placed at the end of a loop initiation because the interpreter reads this as the only line inside the loop. and question scores below. == (two equal signs) compares the memory location of non-primitive objects. (*) Incorrect. What is wrong with this code? Mark for Review (1) Points It is missing a semicolon. (*) = (single equals sign) compares the value of primitive types such as int or char.

) public class abstract ClassName(... (*) They must be overridden in a non-abstract subclass.. Section 7 (Answer all questions in this section) 41. What is true about the Object class? Mark for Review (1) Points (Choose all correct answers) . feedback.. They must be overloaded..} (*) Correct 40. Correct Previous Page 8 of 10 Next Summary Test: Java Fundamentals Final Exam Review your answers. There is nothing wrong with this code. (*) Correct Section 7 (Answer all questions in this section) 39. An asterisk (*) indicates a correct answer.. and question scores below.. It does not handle the exception. Mark for Review (1) Points abstract public class ClassName{. It gives you an out of bounds exception.} public abstract ClassName(. (*) They may contain implementation. Which of the following are true about abstract methods? Mark for Review (1) Points (Choose all correct answers) They cannot have a method body. Identify the correct way to declare an abstract class..) public abstract class ClassName{. (*) They must be declared in an abstract class.

could it be directly accessed or modified by a subclass? Why or why not? Mark for Review (1) Points Yes. Any variable passed through inheritance can be changed. An access modifier is a keyword that allows subclasses to access methods. (*) Its methods can be overloaded in subclasses. True or false? Mark for Review (1) Points True (*) False Correct 43. more efficient coding by using exiting code for new applications. It is the highest superclass. Correct 44. Which of the following are access specifiers? Mark for Review (1) Points (Choose all correct answers) protected (*) . Its methods can be overridden in subclasses. A private variable can only be modified by the same class with which it is declared regardless of its inheritance. but private methods cannot. A programming philosophy that promotes protecting data and hiding implementation in order to preserve the integrity of data and methods. data. (*) Correct 42. No. It restricts access to a specified segment of code. Nothing inherited by the super class can be changed in the subclass. and constructors from their parent class. 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. (*) It extends other classes. Correct 45. Yes. (*) A programming philosophy that promotes simpler. If a variable in a superclass is private. (*) No. A subclass inherits full access to all contents of its super class.

A variable argument method that returns an array. public (*) secured default (no access modifier) (*) private (*) Correct Previous Page 9 of 10 Next Summary Test: Java Fundamentals Final Exam Review your answers. return carA.setTurbo("yes").} (*) c) String upgrade(String carA){ carA="Turbo". A type of access specifier that only allows access from inside the same class.} b) Automobile upgrade(Automobile carA){ carA. An asterisk (*) indicates a correct answer. feedback. Correct 47. return carA. Section 7 (Answer all questions in this section) 46. 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. return carA. and question scores below. Which of the following is the correct way to code a method with a return type an object Automobile? Mark for Review (1) Points a) Automobile upgrade(String carA){ carA="Turbo".} d) upgrade(Automobile carA) Automobile{ .

It is not possible to return an object. What is printed by the following code segment? Mark for Review (1) Points .setTurbo("yes"). 49. Static methods can read instance variables. True or false? Mark for Review (1) Points True False (*) Incorrect. Correct 48. feedback.} None of the above. Refer to Section 7 Lesson 2. Static methods can't act like "setter" methods. True or false? Mark for Review (1) Points True False (*) Correct Previous Page 10 of 10 Summary Review your answers. and question scores below. Section 4 (Answer all questions in this section) 1. Static classes are designed as thread safe class instances. True or false? Mark for Review (1) Points True False (*) Correct 50. An asterisk (*) indicates a correct answer. return carA.carA.

What is printed? Mark for Review (1) Points Cayrbniz CayrbnizCayrbniz yr (*) ay ArrayIndexOutofBoundsException is thrown . Consider the following code snippet.\\ \\\\ (*) \\\\\\\ \ Correct 2.

Incorrect. What will the following code segment output? String s="\\n###BOT_TEXT###quot;\n\\n###BOT_TEXT###quot;". Refer to Section 4 Lesson 4. The following program prints "Not Equal".println(s). True or false? Mark for Review (1) Points True False (*) Incorrect. 3. Refer to Section 4 Lesson 4.out. 5. Which of the following creates a String named Char? . System. 4. Mark for Review (1) Points ###BOT_TEXT###quot; ###BOT_TEXT###quot; ""\ "" \ "" \ " \ " (*) "###BOT_TEXT###quot;###BOT_TEXT###quot;" Incorrect. Refer to Section 4 Lesson 4.

Refer to Section 4 Lesson 1. (*) char Char. . Incorrect.Mark for Review (1) Points char string. (*) To navigate a hierarchy of information. char char. What is the purpose of the Eclipse Editor Area and Views? Mark for Review (1) Points (Choose all correct answers) To modify elements. (*) To choose the file system location to delete a file. Correct Section 4 (Answer all questions in this section) 6. String char. String Char.

.7. 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 Incorrect. 8.class file Mark for Review (1) Points Collect Compile (*) Package Assemble Incorrect. Refer to Section 4 Lesson 1. You need to _______________ Java code to generate a . Refer to Section 4 Lesson 1.

Refer to Section 4 Lesson 2. Refer to Section 4 Lesson 1. True or false? True False (*) Incorrect. 12. Eclipse does not provide views to help you navigate a hierarchy of information. When importin g another package into a class you must import only the package classes that will be called and not Mark for Review (1) Points the entire package . True or False? Mark for Review (1) Points True False (*) Correct 10. Which of the two diagrams below illustrate the general form of a Java program? Mark for Review (1) Points Example A Example B (*) . 11.9. For every opening curly brace { there does not need to be a closing curly brace} for the program to compile without error. True or False? Mark for Review (1) Points True False (*) Incorrect.

double number=6e5. What two values can a boolean variable have? Mark for Review (1) Points Numbers and characters True and false (*) Relational and logic operators Arithmetic and logic operators Integers and floating point types Correct Section 5 (Answer all questions in this section) . Mark for Review (1) Points double number=6*10^5. 14. (*) double number=6(e5). Refer to Section 4 Lesson 3. Select the statement that declares a number of type double and initializes it to 6 times 10 to the 5th power. Correct 13. double number=6*10e5. Incorrect.

5 3. 8 (*) 5. Which of the following is true about a do-while loop? Mark for Review (1) Points It is a post-test loop. Refer to Section 5 Lesson 2. } 4. (Answer all questions in this secti on) 16. 8 5. 27. int x = 1. 11 . 27. 8. It continues looping until the condition becomes false. How many times will the following loop be executed? What is the value of x after the loop has finished? What is the value of count after the loop has finished? int count = 17. It is a modified while loop that allows the program to run through the loop once before testing the boolean condition.15. 30. Mark for Review (1) Points count-=3. All of the above. 9. (*) Incorrect. 27 3. while(count > x){ x*=3.

Refer to Section 5 Lesson 2. . They allow for repeating code until a certain argument is met. All of the above. Refer to Section 5 Lesson 1.Incorrect. In an if-else construct the condition to be evaluated must end with a semi-colon. True or false? Mark for Review (1) Points True False (*) Incorrect. They allow for repeating code a variable number of times. Why are loops useful? Mark for Review (1) Points They save programmers from having to rewrite code. (*) Incorrect. 17. Refer to Section 5 Lesson 2. 18.

19. Because it allows the user to enter an input in the console screen and prints out a message that the user input was successfully read in. Which of the following could be a reason to use a switch statement in a Java program? Mark for Review (1) Points Because it allows the code to be run through until a certain conditional statement is true. Refer to Section 5 Lesson 1. (*) Because it terminates the current loop. Incorrect. Incorrect. Refer to Section 6 Lesson 1. . Because it allows the program to run certain segments of code and neglect to run others based on the input given. Refer to Section 5 Lesson 1. What is the output of the following segment of code? Mark for Review (1) Points 321111 11 (*) 111 1111 This code doesn't compile. 20. This keyword is used to instruct specific code when the input for a switch statement that does not match any of the cases. 2 1. Mark for Review (1) Points Switch Case Break Default (*) None of the above Incorrect.

(*) Incorrect. Incorrect. Refer to Section 6 Lesson 1. Which of the following explains why this gives you an exception? Mar k for Review (1) Points . float []averages. double marks[5]. counter int[]. What is the output of the following segment of code? Mar k for Review (1) Points 321123 642 642246 (*) 312213 This code doesn't compile. Suppose you misspell a method name when you call it in your program.22. Which of the following statements is not a valid array declaration? Mar k for Review (1) Points int number[]. 25. 24. Refer to Section 6 Lesson 1. Correct 23. What is the output of the following segment of code if the command line arguments are "a b c d e f g"? Mar k for Review (1) Points f e (*) c d This code doesn't compile.

what is the fastest run. Because the interpreter tries to read the method but when it finds the method you intended to use it crashes. 26.time? Mark for Review (1) Points n n^2 lg(n) (*) n*lg(n) Incorrect. the correct spelling of the method was initialized. 27. Refer to Section 6 Lesson 3. it will give you an error when the program is compiled. Selection sort is efficient for large arrays. Because the parameters of the method were not met. (*) Incorrect. True or false? Mark for Review (1) Points . Refer to Section 6 Lesson 2. Because the interpreter does not recognize this method since it was never initialized. Of the options below. True or false? Mark for Review (1) Points True False (*) Correct 28. This will not give you an exception. Binary searches can be performed on sorted and unsorted data.

A sequntial search is an iteration through the array that stops at the index where the desired element is found. What is the Java Applet? Mark for Review (1) Points (Choose all correct answers) It is the virtual machine that translates Java code into a representation that the computer can understand. 31 . Refer to Section 7 Lesson 4. (*) Because the . A web-based Java program that is embedded into a web browser. (*) A graphic visual included in Java. True False (*) Correct 29. True or false? Mark for Review (1) Points True (*) False Correct Section 7 (Answer all questions in this section) 30. Incorrect. (*) There is no such thing as a Java Applet. Why is it not possible to extend more than one class at a time in an inherita nce hierarch Mark for Review (1) Points y chain? 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.

A programming philosophy that promotes protecting data and hiding implementation in order to preserve the integrity of data and methods.needOil(SqueakyRobot). Correct 33. It is possible to extend more than one class at a time. 32. SqueakyRobot. Refer to Section 7 Lesson 4.computer cannot handle code that complex. To prevent confusion for the programmer. Which of the following is the correct way to call an overriden method needOil() of a super class Robot in a subclass SqueakyRobot? Mark for Review (1) Points Robot. (*) .needOil().needOil(). more efficient coding by using exiting code for new applications. 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. super. It restricts access to a specified segment of code. (*) A programming philosophy that promotes simpler. Incorrect.

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.needOil(Robot). Refer to Section 7 Lesson 4. Incorrect. Private cannot be used as an access modifier. Choose all that apply. True or False? Mark for Review (1) Points True (*) False Correct 35. 34. Final cannot be used as an access modifier. Identify the error(s) in the class below. It is possible to overload a method that is not a constructor.

The method makes changes to the object and you wish to continue to use the updated object outside of the method. It has faster performance than returning a primitive type. 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. (*) Incorrect. It is not possible to return an object. 37. Having more than one constructor with the same name but different arguments. . Tree oak) {//code here }. A type of argument that enables calling the same method with a different number of arguments. Refer to Section 7 Lesson 2. Which of the following is the definition for a variable argument method? Mark for Review (1) Points A way to create a new class. (*) Tree bloom (pine. oak) {//code here }. Specifies accessibility to code. Refer to Section 7 Lesson 2. 36. Which segment of code correctly defines a method that contains two objects of class Tree as parameters? Mark for Review (1) Points void bloom(Tree pine. Incorrect. Incorrect. Refer to Section 7 Lesson 2. (*) None of the above. 38.

It is possible to inherit from an abstract class. Tree oak {//code here }. None of the above. (*) Incorrect. True or false? Mark for Review (1) Points True False (*) Incorrect. Refer to Section 7 Lesson 5.void bloom. Tree pine. A class that cannot be initiated. Abstract classes cannot implement interfaces. 41. Refer to Section 7 Lesson 5. What is Polymorphism? Mark for Review (1) Points A way of redefining methods with the same return type and parameters. objects cannot be passed as parameters. 40. Correct 39. A way to create multiple methods with the same name but different parameters. The concept that a variable or reference can hold multiple types of objects. True or false? Mark for Review (1) Points True (*) False .

Correct

42. Static methods can return any object type. True or false?

Mark for Review (1) Points

True (*)

False

Incorrect. Refer to Section 7 Lesson 3.

43. A non-linear recursive method is less expensive than a linear recursive method. True or
false? Mark for Review (1) Points

True

False (*)

Incorrect. Refer to Section 7 Lesson 3.

44. Forward thinking helps when creating linear recursive methods. True or false?

Mark for Review (1) Points

True

False (*)

Correct

45. What is wrong with the following class declaration?

class Account{ ; private int number; private String name;; public Account; }

Mark for Review (1) Points

Classes cannot include strings.

Classes cannot include mixed data types.

The constructor method has no definition. (*)

There is nothing wrong.

Incorrect. Refer to Section 7 Lesson 1. 4 6 . Which of the following creates an instance
of the class below? Mar k for Review (1) Points

ThisClass t=new ThisClass();

ThisClass t;

ThisClass t=new ThisClass(3,4);

ThisClass t=new ThisClass(5); (*)

Incorrect. Refer to Section 7 Lesson 1.

47. A class can only have one constructor. True or false?

Mar k for Review (1) Points

True

False (*)

Incorrect. Refer to Section 7 Lesson 1.

48. Which of the following creates a method that returns a boolean value? Mar k for Review
(1) Points

(*)

None of the above.

Correct

49. The constructor method must always have at least one parameter. True or false? Mar k for
Review (1) Points

True

False (*)

Incorrect. Refer to Section 7 Lesson 1.

50. Identify the driver class that correctly initializes employees Jane and Brandon. The
Employee class is below.

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 }

Mar k for Review (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();

2. int. double. long. 2 . Refer to Section 7 Lesson 1. String char. } } Incorrect. int. Test: Java Fundamentals Final Exam Review your answers. double. Short char. 10. long. long. Mark for Review (1) Points char. "hello") with its respective data type. float. Which of the following is the name of a Java primitive data type? Mark for Review (1) Points . String (*) boolean. int. 100L. boolean. float. long.Employee Brandon = new Employee(). int. Section 4 (Answer all questions in this section) 1 . 10. byte. and question scores below. long. Match each of the following literals ('x'. Refer to Section 4 Lesson 3. String char. An asterisk (*) indicates a correct answer. feedback. String Incorrect.

static methods. (*) Contains a main method.Object Rectangle double (*) String Incorrect. Contains classes that define objects. . Incorrect. a package. None of the above. 3 . Refer to Section 4 Lesson 2. Refer to Section 4 Lesson 3. Which of the following defines an object class? Mark for Review (1) Points Contains a main method and other static methods. and classes that define objects.

4 . 5 . True or false? Mark for Review (1) Points True (*) False Incorrect. True or false? Mark for Review (1) Points True (*) . The followin g code is an example of creating a String reference : String s. The == operator tests if two String references are pointing to the same String object. Refer to Section 4 Lesson 2. Refer to Section 4 Lesson 4. 6 . Which of the two diagrams below illustrate the general form of a Java program? Mark for Review (1) Points Example A Example B (*) Incorrect.

String s2 = "abcdef". Which of the following would equate to false? Mark for Review (1) Points s1 == s2 s1 = s2 s3 == s1 (*) s1.equals(s1) Correct 8. Consider the following code snippet. String s3 = new String(s1). 7. What is printed? Mark for Review (1) Points 0 1 (*) 2 .False Incorrect.equals(s2) s3. Given the code String s1 = "abcdef". Refer to Section 4 Lesson 4.

10. True or false? Mark for Review (1) Points True (*) False Incorrect. The location where all projects are developed and modified. The String methods equals and compareTo perform similar functions and differ in their return type. Refer to Section 4 Lesson 4. A workspace is: Mark for Review (1) Points The physical location onto which you will store and save your files. 11. All of the above.11 12 Incorrect. A perspective is described as: Mark for Review (1) Points A combination of views and editors (*) . Refer to Section 4 Lesson 1. (*) Incorrect. The location where you can have one or more stored perspectives. Refer to Section 4 Lesson 4. 9.

Incorrect. Refer to Section 4 Lesson 1. When you open more than one file in Eclipse the system will __________________. 13. (*) Put the new file opened in a View area only. None of the above. Use tabs to display all files open.A combination of views and windows A combination of editor tabs None of the above Correct 12. What symbols are required for a compiler to ignore a comment? Mark for Review (1) Points // (*) /* . Mark for Review (1) Points Close the previously opened file.

*/ /*/ Incorrect. A combination of views and editors are referred to as _______________. 14. Mark for Review (1) Points A workspace A physical location A perspective (*) All of the above Correct Section 5 (Answer all questions in this section) 15. Refer to Section 4 Lesson 1. Which of the following correctly matches the switch statement keyword to its function? Mark for Review (1) Points (Choose all correct answers) switch: tells the compiler the value to compare the input against .

char. ! (*) !=. Refer to Section 5 Lesson 1. but not limited to. int.== . The three logic operators in Java are: Mark for Review (1) Points &&. ||. 16. switch statements work on all input types including. True or false? Mark for Review (1) Points True False (*) Correct 17. and String.=.default: signals what code to execute if the input does not match any of the cases (*) case: signals what code is executed if the user input matches the specified element (*) if: records the user's input and sends it to the case statements to find a possible match switch: identifies what element will be compared to the element of the case statements to find a possible match (*) Incorrect.

= Correct 18.|. All of the above.&&. True or false? Mark for Review (1) Points True False (*) . It is a modified while loop that allows the program to run through the loop once before testing the boolean condition. Which of the following is true about a do-while loop? Mark for Review (1) Points It is a post-test loop. Refer to Section 5 Lesson 2. (*) Incorrect.= &. A counter used in a for loop cannot be initialized within the For loop header. 19. It continues looping until the condition becomes false.!=.

8. 83. 22. 29. 17} {83. 22. 29. 28. 3. 29. 1.Correct 20. 83} (*) Correct . 3. In the code fragment below. 50. 50. 29. 83} {1. 22. 1} {1. the syntax for the for loop's initialization is correct. 28. 71.29. 4. 71. } } } Mark for Review (1) Points True False (*) Incorrect. 50. 17. 9. 28. 0. 2. 1. 17. 1.Println ("i: "+i). 21. 5. 22. 71. 71. 50. 1. 50. 3. 17. 1. 83. 22} Mark for Review (1) Points {71. Which of the following is the correct lexicographical order for the conents of the int array? {17. True or false? public class ForLoop { public static void main (String args[]) { for ((int 1=10) (i<20) (i+ +))<br> {System. Refer to Section 5 Lesson 2. 3} {1. 3. 1. 7. 28.out. 1. 3. 6. 28.

23. . 22. Refer to Section 6 Lesson 2. what is the fastest run-time? Mark for Review (1) Points n n^2 lg(n) (*) n*lg(n) Incorrect. Refer to Section 6 Lesson 2. True or Mark for Review false? (1) Points True False (*) Incorrect. Selection sort is efficient for large arrays. Why might a sequential search be inefficient? Mark for Review (1) Points It utilizes the "divide and conquer" method. Of the options below. 24. which makes the algorithm more error prone.

Refer to Section 6 Lesson 1. Which of the following declares a one dimensional array named names of size 8 so that all entries can be Strings? Mark for Review (1) Points String names=new String[8]. Refer to Section 6 Lesson 2. which is inefficient on large data sets. String[] names=new String[8].It requires incrementing through the entire array in the worst case. It is never inefficient. which is inefficient on large data sets. 25. . (*) String[] name=String[8]. (*) It involves looping through the array multiple times before finding the value. the following declares and initializes a one dimension al array named words of size 3 so that all entries can be Strings? Review (1) Points String strings=new String[3]. Incorrect. String[] name=new Strings[8]. 26Which of Mark for . Incorrect.

28. 27.String[] word={"Over". Refer to Section 6 Lesson 1. What will be the content of the array variable table after executing the following code? Mark for Review (1) Points 111011001 100010 001 1 0 0 1 1 0 1 1 1 (*) 001010100 Correct ."the". String[] words={"Oracle". Refer to Section 6 Lesson 1. Incorrect. Mark for Review (1) Points True (*) False Incorrect."mountain"}. True or false? int k[] = new int[10]. The following array declaration is valid. (*) String[] word=new String[3]."Academy"}].

The following statement compiles and executes. Section 7 (Answer all questions in this section) 30. Mark for Review (1) Points numFeet must be an int. True or false? Mark for Review (1) Points True (*) False Incorrect. Refer to Section 6 Lesson 3. True or false? Mark for Review (1) Points True .grows(numFeet). grows must be the name of an instance field.29. grows must be the name of a method. Correct 3 1. It is possible to throw and catch a second exception inside a catch block of code. The basic unit of encapsulat ion in Java is the primitive data type. What do you know for certain? tree. (*) tree must be a method. tree must be the name of the class.

Instance variable names may only contain letters and digits.print(" ". 34. Refer to Section 7 Lesson 1. System. 33. True or false? Mark for Review (1) Points True False (*) Incorrect.75. 13 0.out. Refer to Section 7 Lesson 1.print(doNothing(n)). What is the output of the following code segment: int n = 13. return (double) 12/n. 21 . A class can only have one constructor. n). } Mark for Review (1) Points 1.out. where the code from the method doNothing is: public double doNothing(int n) { n = n + 8. System. True or false? Mark for Review (1) Points True False (*) Incorrect.False (*) Correct 32.571.

36. 13 (*) Incorrect.571. 21 0. Refer to Section 7 Lesson 1. What value will return for j when the setValue method is called? Mark for Review (1) Points 31 32 10 11 (*) Incorrect. True or false? Mark for Review (1) Points True (*) False Incorrect.75.1. Refer to Section 7 Lesson 1. 35. 37. Static methods can write to class variables. Refer to Section 7 Lesson 3. Static methods can read instance variables. True or false? Mark for Review (1) Points True .

Refer to Section 7 Lesson 5. True or false? Mark for Review (1) Points True False (*) Incorrect. If a class is immutable then it must be abstract. Static methods can't act like "setter" methods. True or false? Mark for Review (1) Points True False (*) Correct 39. Refer to Section 7 Lesson 3. Which of the following can be declared final? Mark for Review (1) Points Classes Methods . 40.False (*) Incorrect. 38.

(*) .returnList(nums). II. Why are hierarchies useful for inheritance? Mark for Review (1) Points They keep track of where you are in your program. Refer to Section 7 Lesson 5. III. 42. They restrict a superclass to only have one subclass. I only I and III (*) II only II and III I. They are used to organize the relationship between a superclass and its subclasses. II. } Which of the following program segments in Test's client class will compile with no errors? I. They organize constructors and methods in a simplified fashion. 41. List nums = new ArrayList(). ArrayList nums1 = new ArrayList().returnList(nums1).Local variables Method parameters All of the above (*) Incorrect. nums = Test. and III Incorrect. Refer to Section 7 Lesson 5. Consider the following method of the class Test: public static List returnList(List list) { return list. List nums2 = Test. Mark for Review (1) Points nums = Test.returnList(nums). ArrayList nums = new ArrayList().

(*) No. True or false? Mark for Review (1) Points True (*) False Correct 4 6. Any variable passed through inheritance can be changed. It is possible for a subclass to be a superclass. A subclass inherits full access to all contents of its super class. Refer to Section 7 Lesson 4. could it be directly accessed or modified by a subclass? Why or why not? Mark for Review (1) Points Yes.Incorrect. Refer to Section 7 Lesson 4. 43. No. Yes. If you inherit a class. Correct 44. Which of the follow ing is the definit ion for a variabl e argum ent metho d? . you do not inherit the class' constructors. Nothing inherited by the super class can be changed in the subclass. 45. If a variable in a superclass is private. but private methods cannot. True or false? Mark for Review (1) Points True (*) False Incorrect. A private variable can only be modified by the same class with which it is declared regardless of its inheritance.

Refer to Section 7 Lesson 2. Which of the following is the definition of a constructor? Mark for Review (1) Points A keyword that specifies accessibility of code. Specifies accessibility to code. A variable in a method declaration that gets passed into the method. 47. Correct 48. A type of argument that enables calling the same method with a different number of arguments.Mark for Review (1) Points A way to create a new class. (*) Incorrect. Having more than one constructor with the same name but different arguments. 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. 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.

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.

Incorrect. Refer to Section 7 Lesson 2.

49. 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.

50. Which of the following is the correct way to code a method with a return type an object
Automobile?

Mark for Review (1) Points

Automobile upgrade(String carA){ carA="Turbo"; return carA;}

Automobile upgrade(Automobile carA){ carA.setTurbo("yes"); return carA;} (*)

String upgrade(String carA){ carA="Turbo"; return carA;}

upgrade(Automobile carA) Automobile{ carA.setTurbo("yes"); return carA;}

None of the above. It is not possible to return an object.

Correct

1. Suppose that str1 and str2 are two strings. Which of the statement s or expression s are
valid?

Mark for Review (1) Points

String str3 = str1 - str2;

str1 += str2; (*)

str1 >= str2

Str1 -= str2;

Incorrect. Refer to Section 4 Lesson 4.

2. The following program prints "Not Equal". True or false? Mark for

Review (1) Points

True

False (*)

Incorrect. Refer to Section 4 Lesson 4.

3. When a String object is created it must be assigned a value. True or false?

Mark for Review (1) Points

True

False (*)

Incorrect. Refer to Section 4 Lesson 4.

4. Which of the following creates a String reference named s and instantiates it?

Mark for Review (1) Points

(Choose all correct answers)

String s=""; (*)

s="s";

String s;

String s=new String("s"); (*)

Incorrect. Refer to Section 4 Lesson 4.

double. Incorrect. int. double A=1/2bh. long and short . long. byte. byte. double A=(double)1/(double)2*b*h. Which line of Java code Mark for Review properly calculates the area of a triangle using A=1/2(b)(h) where b and h are Java primitive integers? (1) Points double A=1/2*b*h. Refer to Section 4 Lesson 3. 7. What is printed by the following code segment? Mark for Review (1) Points \\ \\\\ (*) \\\\\\\ \ Correct 6. double. char. (*) double A=(double)(1/2)*b*h.5. and short (*) boolean. string. float. thread. What are Java's primitive types? Mark for Review (1) Points boolean. int.

and provides a level of access control. Refer to Section 4 Lesson 3. int. char. and classes that define objects. Contains a main method. Which of the following defines a driver class? Mark for Review (1) Points Contains a main method and other static methods. 9. a package. long and short boolean. double. thread. Refer to Section 4 Lesson 2. long and short boolean. A _______________ is used to organize Java related files. char. 10. None of the above. stringbuffer. int. float. char.object. byte. (*) Provides the compiler information that identifies outside classes used within the current class. float. static methods. long and short Incorrect. The following defines a package keyword: Mark for Review (1) Points Defines where this class lives relative to other classes. int. float. . (*) Contains classes that define objects. Precedes the name of the class. 8. string. thread. Incorrect. Incorrect. Refer to Section 4 Lesson 2.

For every opening curly brace { there does not need to be a closing curly brace} for the program to compile without error. 11. Refer to Section 4 Lesson 1. Four variables are required to support a conversion of one unit of measure to another unit .Mark for Review (1) Points Project Workspace Package (*) Collection Incorrect. True or False? Mark for Review (1) Points True False (*) Correct 12. Refer to Section 4 Lesson 1. You can return to the Eclipse Welcome Page by choosing Welcome from what menu? Mark for Review (1) Points File Edit Help (*) Close Incorrect. 13.

count-=3. } Mark for Review (1) Points 4. When converting gallons to liters its best to put the calculation result into a variable with a _______________ data type. Mark for Review (1) Points int double (*) boolean None of the above Correct Section 5 (Answer all questions in this section) 15. 27 . Refer to Section 4 Lesson 1. 8. int x = 1. How many times will the following loop be executed? What is the value of x after the loop has finished? What is the value of count after the loop has finished? int count = 17.of measure. True or False? Mark for Review (1) Points True False (*) Incorrect. while(count > x){ x*=3. 14.

return. All of the above. } Mark for Review (1) Points continue. i++){<br> if(i%2 == 0) //your answer here else k+=3. 11 Correct 16. 30. (*) Incorrect. What should replace the comment "//your answer here" in the code below if the code is meant to take no action when i % 2 is 0 (in other words when i is even)? for(int i = 0. 27. (*) break. 8 (*) 5. i < 10. 8 5. They allow for repeating code until a certain argument is met.3. 27. 5 3. . 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. 9. 17. Refer to Section 5 Lesson 2.

String input = in.next(). Which of the following lines of code reads in the user's input and sets it equal to a new String called input? Mark for Review (1) Points String input = in. (*) String input = in. String input = new String in. True or false? Mark for Review (1) Points True False (*) . 19.nextInt(). Correct 18.close(). Refer to Section 5 Lesson 1. Incorrect.next(). The following prints Yes on the screen. Consider that a Scanner has been initialized such that: Scanner in = new Scanner(System.k+=1.in).

=.Correct 20.<=. True or false? int[] q = new int[8].>= (*) >.==.!=.<.!=. The followin g creates a referen ce in memory named q that Mark for Review (1) Points can refer to six differen t integers via an index.=> Correct 21.<.!.!=.=<. True False (*) Correct 22.<.=.>= >. double array[] = new double[8].>= >.<. which of the following are true? Mark for Review (1) Points array[0] is undefined . After execution of this statement.<=.<=. The six relational operators in Java are: Mark for Review (1) Points >.=.

True or false? double[] q = new double[8]. Mark for Review (1) Points True (*) False Correct 24. Refer to Section 6 Lesson 1. 23. The following creates a reference in memory named q that can refer to eight different doubles via an index. True or false? Mark for Review (1) Points True False (*) Incorrect. Refer to Section 6 Lesson 1. The following segment of code prints all five of the command line arguments entered into this program.length is 8 (*) Incorrect.array[4] is null array[2] is 8 array. 25. 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 .

middle. Refer to Section 6 Lesson 2. True or false? Mark for Review (1) Points True False (*) . Which searching algorithm involves using a low.Merge Sort (*) Selection Sort Binary Search All of the above Incorrect. 26. Binary searches can be performed on sorted and unsorted data. and high index value to find the location of a value in a sorted set of data (if it exists)? Mark for Review (1) Points Sequential Search Merge Sort Selection Sort Binary Search (*) All of the above Correct 27.

(*) The end of the program. Section 7 (Answer all questions in this section) . Incorrect. Refer to Section 6 Lesson 2. 28. True or false? Mark for Review (1) Points True False (*) Correct 29. If an exception has already been thrown. what will the interpreter read next in the program? Mark for Review (1) Points The next line of the program even if it is not the catch block of code. Refer to Section 6 Lesson 3. Selection sort is efficient for large arrays.Incorrect. Where the program catches the exception. The user input.

True or false? Mark for Review (1) Points True (*) False Incorrect. Refer to Section 7 Lesson 2.30. 32. 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. Refer to Section 7 Lesson 2. It is not possible to return an object. It is possible to return an object from a method. Incorrect. (*) None of the above. It is possible to overload a method that is not a constructor. It has faster performance than returning a primitive type. 31. True or False? Mark for Review (1) Points True (*) False Correct . The method makes changes to the object and you wish to continue to use the updated object outside of the method.

return carA.} Automobile upgrade(Automobile carA){ carA.} upgrade(Automobile carA) Automobile{ carA. elems) {//code} (*) String easyArray(. Which segment of code represents a correct way to define a variable argument method? Mark for Review (1) Points String easyArray(String . 35. return carA..} None of the above.. Correct 34.} (*) String upgrade(String carA){ carA="Turbo". return carA. car2=car1.. It is not possible to return an object. The reference car2 points to an exact copy of the Car Object that car1 references... What is true about the code below: Car car1=new Car(). Car car2=new Car()..setTurbo("yes"). String elems) {//code} String .. ..setTurbo("yes"). Refer to Section 7 Lesson 2. Which of the following is the correct way to code a method with a return type an object Automobile? Mark for Review (1) Points Automobile upgrade(String carA){ carA="Turbo".33. easyArray(String elems) {//code} Integer easyArray . (*) There are no more Car objects in memory. return carA. (int elems) {//code} Incorrect. Mark for Review (1) Points (Choose all correct answers) The references car1 and car2 are pointing to two Car Objects in memory.

tree must be the name of the class. There is a Car object that car2 referenced that is now slated for removal by the garbage collector. (*) Incorrect. Refer to Section 7 Lesson 1. The basic unit of encapsulation in Java is the primitive data type. 37. Incorrect. Refer to Section 7 Lesson 1. (*) tree must be a method. True or false? Mark for Review (1) Points True False (*) Correct . grows must be the name of an instance field. grows must be the name of a method. The following statement compiles and executes. What do you know for certain? tree.There is a Car object that car1 referenced that is now slated for removal by the garbage collector. Mark for Review (1) Points numFeet must be an int. 36 .grows(num Feet).

out.30).75. return (double) 12/n. n).out. True or false? Animal a=new Animal(). 13 (*) Incorrect.571. where the code from the method doNothing is: public double doNothing(int n) { n = n + 8.print(doNothing(n)). Refer to Section 7 Lesson 1. } Mark for Review (1) Points 1. 21 1. Refer to Section 7 Lesson 1. Animal cat=Animal(50. 21 0. 40. System.571.75.38. Which of the following creates an object from the Animal class listed below: Mark for Review (1) Points Animal cat=new Animal(). 39. . Mark for Review (1) Points True (*) False Incorrect. What is the output of the following code segment: int n = 13. 13 0.print(" ". System. The following code creates an object of type Animal.

A linear recursive method directly calls how many copies of itself in the recursive case? Mark for Review (1) Points 0 1 (*) 2 or more Correct 42. Refer to Section 7 Lesson 1. Any instance of the same class can assign a new value to a static variable. (*) Animal cat=new Animal(50).Animal cat=new Animal(50. Incorrect. True or false? Mark for Review (1) Points True False (*) Correct 43. 41.30). Static methods can't act like "setter" methods. True or false? Mark for Review (1) Points True (*) False Correct .

and constructors from their parent class. Consider creating a class Square that extends the Rectangle class provided below. } Mark for Review (1) Points True False (*) Correct 45. data. Which of the following correctly describes the use of the keyword super? Mark for Review (1) Points A keyword that restricts access to only inside the same class. According to the following class declaration. A keyword that allows subclasses to access methods. runSpeed can be modified in class Cat. . (*) A keyword that signals the end of a program. True or false? public class Tiger extends Cat{ public int runSpeed. Knowing that a square always has the same width and length.44. Correct 4 6 . which of the following best represents a constructor for the Square class? Mar k for Review (1) Points (*) None of the above. A keyword that allows access from anywhere.

A structure that categorizes and organizes relationships among ideas. Identify the step(s) in creating a Triangle Applet that displays two triangles. (*) Override the paint method to include the triangles. A programming philosophy that promotes protecting data and hiding implementation in order to preserve the integrity of data and methods. (*) Draw the 2nd triangle using the inherited fillPolygon method. more efficient coding by using exiting code for new applications. concepts of things with the most general at the top and the most specific at the bottom. (*) Run and compile your .Correct 47. True or false? Mar k for Review (1) Points True (*) False Correct 49. (*) Draw the triangle using the inherited fillPolygon method. 48. If Oak extends Tree. Mar k for Review (1) Points (Choose all correct answers) Extend Applet class to inherit all methods including paint. it is possible to declare an object such that Tree grandfatherT = new Oak(). (*) Incorrect. Refer to Section 7 Lesson 4. What is encapsulation? Mar k for Review (1) Points A keyword that allows or restricts access to data and methods. A programming philosophy that promotes simpler.

50. Which of the following statements will change the length of s to the largest length? Mark for Review (1) Points s. (*) str1 >= str2 Str1 -= str2. with the same name. What does it mean to override a method? Mar k for Review (1) Points It is a way to create multiple methods with the same name but different parameters. (*) Incorrect. It allows an array to contain different object types. Which of the following creates a String named Char? Mark for Review (1) Points char string.trim() s. (*) Correct 2. parameters. str1 += str2.str2. Correct 3. Suppose that str1 and str2 are two strings. and return type.code. (*) None of the above.replace("a". It restricts the privacy of the method to only be accessible from inside the same class. Refer to Section 7 Lesson 5. 1. .substring(2) s. Refer to Section 7 Lesson 5. Incorrect. "aa") s. It is a way of redefining methods of a parent class inside the child class. Given the code: String s = new String("abc"). Which of the statements or expressions are valid? Mark for Review (1) Points String str3 = str1 .toUpperCase() None of the above will change the length of s.

println(s). Mark for Review (1) Points int x=(double)2. System. What two values can a boolean variable have? Mark for Review (1) Points Numbers and characters True and false (*) Relational and logic operators . which line of Java code properly casts one type into another without data loss? int i=3. double x= double i/j.println(forest. double x=(double)(i/j).length()). 7. 5. Refer to Section 4 Lesson 4. String char. double x=i/j.54. Correct 4.String Char. What is printed? Mark for Review (1) Points 5 (*) 6 7 Black Forest Incorrect.out. Refer to Section 4 Lesson 3. What will the following code segment output? String s="\\n###BOT_TEXT###quot;\n\\n###BOT_TEXT###quot;". 6. Given the following declaration. Consider the following code snippet String forest = new String("Black"). double y=2. double x=(double)i/j. Refer to Section 4 Lesson 4. System. Mark for Review (1) Points ###BOT_TEXT###quot; ###BOT_TEXT###quot; ""\ "" \ "" \ " \ " (*) "###BOT_TEXT###quot;###BOT_TEXT###quot;" Incorrect.54. char char.j=4. (*) char Char.out. (*) Incorrect.

What is the purpose of the Eclipse Editor Area and Views? Mark for Review (1) Points (Choose all correct answers) To modify elements. Refer to Section 4 Lesson 2. a package. (*) Contains classes that define objects. None of the above. (*) To choose the file system location to delete a file. B-Main Method. Incorrect. None of the above. (*) Contains a main method. 8. a package. Refer to Section 4 Lesson 1. In the image below. Incorrect. Refer to Section 4 Lesson 1. 9. and classes that define objects.Arithmetic and logic operators Integers and floating point types Incorrect. Which of the following defines a driver class? Mark for Review (1) Points Contains a main method and other static methods. C-Package A-Package. 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. Refer to Section 4 Lesson 2. (*) To navigate a hierarchy of information. B-MainMethod. . B-Class. and classes that define objects. Contains classes that define objects. Refer to Section 4 Lesson 3. You can return to the Eclipse Welcome Page by choosing Welcome from what menu? Mark for Review (1) Points File Edit Help (*) Close Incorrect. C-Class (*) None of the above Incorrect. 13. static methods. Which of the following defines an object class? Mark for Review (1) Points Contains a main method and other static methods. C-Package A-Class. 11. 12. identify the components. 10. Contains a main method. static methods. Mark for Review (1) Points A-Main Method.

14. k+=1. 19. True or false? Mark for Review (1) Points True (*) False Incorrect." ).out. (*) String input = in. How would you use the ternary operator to rewrite this if statement? if (gender == "female") System.print( (gender == "female") ? "Ms. When the for loop condition statement is met the construct is exited.in). System.print("Ms. Consider that a Scanner has been initialized such that: Scanner in = new Scanner(System." : "Mr. String input = new String in.print( (gender == "female") ? "Mr. Refer to Section 5 Lesson 1.nextInt(). 16. Incorrect. 17.next()." )." : "Ms. Refer to Section 5 Lesson 2. Incorrect. Refer to Section 5 Lesson 2. when you run a Java Application.next(). (*) . Refer to Section 4 Lesson 1. True or false? Mark for Review (1) Points True False (*) Incorrect. Updating the input of a loop allows you to implement the code with the next element rather than repeating the code always with the same element. Mark for Review (1) Points System. True or False? Mark for Review (1) Points True False (*) Correct Section 5 (Answer all questions in this section) 15. Incorrect.out. Refer to Section 5 Lesson 2. the results are displayed in a new window. 18. (*) break.out. i < 10.print("Mr. String input = in. i++){<br> if(i%2 == 0) //your answer here else k+=3. In Eclipse. return.out. What should replace the comment "//your answer here" in the code below if the code is meant to take no action when i % 2 is 0 (in other words when i is even)? for(int i = 0.")."). else System.close(). } Mark for Review (1) Points continue. Which of the following lines of code reads in the user's input and sets it equal to a new String called input? Mark for Review (1) Points String input = in.

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

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

Correct 20. 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 (*)

Incorrect. Refer to Section 5 Lesson 1. 21. It is possible to throw and catch a second
exception inside a catch block of code. True or false? Mark for Review (1) Points True (*)

False

Correct 22. The following segment of code initializes a 2 dimensional array of primitive data
types. True or false?

double[][] a=new double[4][5]; Mark for Review (1) Points True (*)

False

Incorrect. Refer to Section 6 Lesson 1. 23. What will be the content of the array variable table
after executing the following code?

Mark for Review (1) Points 1 1 1 0 1 1 0 0 1

100010001

1 0 0 1 1 0 1 1 1 (*)

001010100

Incorrect. Refer to Section 6 Lesson 1. 24. What is the output of the following segment of
code?

Mark for Review (1) Points 321123

642

642246 (*)

312213

This code doesn't compile.

Correct 25. What is the output of the following segment of code?

int array[][] = {{1,2,3},{3,2,1}}; for(int i=0;i<2;i++) for(int j=0;j<3;j++)
System.out.print(2*array[1][1]); Mark for Review (1) Points 444444 (*)

123321

246642

222222

This code doesn't compile.

Incorrect. Refer to Section 6 Lesson 1. 26. Of the options below, what is the fastest run-time?
Mark for Review (1) Points

n

n^2

lg(n) (*)

n*lg(n)

Incorrect. Refer to Section 6 Lesson 2. 27. Which of the following is the correct
lexicographical order for the conents of the int array?

{17, 1, 1, 83, 50, 28, 29, 3, 71, 22} Mark for Review (1) Points {71, 1, 3, 28,29, 50, 22, 83, 1,
17}

{83, 71, 50, 29, 28, 22, 17, 3, 1, 1}

{1, 1, 17, 22, 28, 29, 3, 50, 71, 83}

{1, 2, 7, 0, 9, 5, 6, 4, 8, 3}

{1, 1, 3, 17, 22, 28, 29, 50, 71, 83} (*)

Incorrect. Refer to Section 6 Lesson 2. 28. Selection sort is efficient for large arrays. True or
false? Mark for Review (1) Points True

False (*)

Incorrect. Refer to Section 6 Lesson 2. 29. 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

Section 7 (Answer all questions in this section) 30. Choose the correct implementation of a
public access modifier for the method divide. Mark for Review (1) Points divide(int a, int b,
public) {return a/b;}

public divide(int a, int b) {return a/b;} (*)

divide(int a, int b) {public return a/b;}

divide(public int a, public int b) {return a/b;}

Incorrect. Refer to Section 7 Lesson 2. 31. 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.

Incorrect. Refer to Section 7 Lesson 2. 32. Which of the following is the correct way to code a
method with a return type an object Automobile? Mark for Review (1) Points Automobile
upgrade(String carA){ carA="Turbo"; return carA;}

Automobile upgrade(Automobile carA){ carA.setTurbo("yes"); return carA;} (*)

String upgrade(String carA){ carA="Turbo"; return carA;}

upgrade(Automobile carA) Automobile{ carA.setTurbo("yes"); return carA;}

None of the above. It is not possible to return an object.

Correct 33. It is possible to overload a method that is not a constructor. True or False? Mark
for Review (1) Points True (*)

False

Correct 34. 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. 35. What is the Java Applet? Mark for Review (1)
Points (Choose all correct answers) It is the virtual machine that translates Java code into a
representation that the computer can understand.

A web-based Java program that is embedded into a web browser. (*)

A graphic visual included in Java. (*)

There is no such thing as a Java Applet.

A constructor is used to create objects. Correct 39. Correct 36. To prevent confusion for the programmer. A programming philosophy that promotes protecting data and hiding implementation in order to preserve the integrity of data and methods. True or false? Mark for Review (1) Points True False (*) Correct 42. 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. 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. True or false? Mark for Review (1) Points True (*) False Correct 41. They organize constructors and methods in a simplified fashion. (*) Correct 37. It is possible to extend more than one class at a time. Mark for Review (1) Points True False (*) Correct 40. Why are hierarchies useful for inheritance? Mark for Review (1) Points They keep track of where you are in your program. The constructor method must always have at least one parameter. The following code creates an object of type Horse: Whale a=new Whale(). 38. True or false? Mark for Review (1) Points True False (*) . (*) Because the computer cannot handle code that complex. Refer to Section 7 Lesson 4. They are used to organize the relationship between a superclass and its subclasses. It restricts access to a specified segment of code. Incorrect. (*) A programming philosophy that promotes simpler. more efficient coding by using exiting code for new applications. They restrict a superclass to only have one subclass. The basic unit of encapsulation in Java is the primitive data type.

Refer to Section 7 Lesson 1. True or false? Mark for Review (1) Points True False (*) Incorrect. A non-linear recursive method calls how many copies of itself in the recursive case? Mark for Review (1) Points 0 1 2 or more (*) Correct 49. Refer to Section 7 Lesson 1. Mark for Review (1) Points True (*) False Correct 45. The following code creates an object of type Animal. 43. car2=car1. it should be implemented as an interface instead. If an abstract class does not have implemented constructors or methods. There is a Car object that car2 referenced that is now slated for removal by the garbage collector. Which of the following can be declared final? Mark for Review (1) Points Classes Methods Local variables Method parameters All of the above (*) Correct 48. Mark for Review (1) Points (Choose all correct answers) The references car1 and car2 are pointing to two Car Objects in memory. True or false? Mark for Review (1) Points True (*) False Incorrect.Incorrect. (*) There are no more Car objects in memory. 47. True or false? Mark for Review (1) Points True (*) . True or false? Animal a=new Animal(). Refer to Section 7 Lesson 5. Car car2=new Car(). 46. The reference car2 points to an exact copy of the Car Object that car1 references. (*) Incorrect. Refer to Section 7 Lesson 5. Static classes can extend their parent class. What is true about the code below: Car car1=new Car(). Abstract class cannot extend another abstract class. There is a Car object that car1 referenced that is now slated for removal by the garbage collector. 44.

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 Test: Java Fundamentals Final Exam Review your answers. An asterisk (*) indicates a correct answer. True or false? Mark for Review (1) Points True (*) False Correct 2 . and question scores below. Consider the following code snippet. 50. What is printed? Mark for Review (1) Points 88888 (*) . feedback. Refer to Section 7 Lesson 3.False Incorrect. Static methods can write to instance variables. Section 4 (Answer all questions in this section) 1 .

Which of the following creates a String named Char? .88888888 1010778 101077810109 ArrayIndexOutofBoundsException is thrown Incorrect. What is printed by the following code segment? Mark for Review (1) Points alligator (*) albatross alligator albatross a1 Correct 4 . 3 . Refer to Section 4 Lesson 4.

Incorrect. Refer to Section 4 Lesson 4. The following program prints "Not Equal": True or false? Mark for Review (1) Points True (*) False Correct Page 1 of 10 . 5 .Mark for Review (1) Points char string. String char. String Char. char char. (*) char Char.

double. int.out. II.out. thread.println("123" + 45).out. (*) I only. What are Java's primitive types? Mark for Review (1) Points boolean. An asterisk (*) indicates a correct answer.println( 12 + "345"). Mark for Review (1) Points All of the above. int. feedback. and short (*) boolean. and question scores below.Test: Java Fundamentals Final Exam Review your answers. char. III. float. I and II only.println( 123 * 100 + 45). System. Refer to Section 4 Lesson 3. byte. System. byte. 7. long and short . Section 4 (Answer all questions in this section) 6. string. Incorrect. long. II and III only. double. System. None of the above. Which of the following statements displays 12345? I.

byte. int. Incorrect. What is the purpose of the Eclipse Editor Area and Views? Mark for Review (1) Points (Choose all correct answers) To modify elements. 9. stringbuffer. int. thread. long and short boolean. float. long and short Correct 8. You can return to the Eclipse Welcome Page by choosing Welcome from what menu? Mark for Review (1) Points File Edit .object. (*) To navigate a hierarchy of information. float. char. char. (*) To choose the file system location to delete a file. Refer to Section 4 Lesson 1. thread. int. long and short boolean. string. double. char. float.

True or False? Mark for Review (1) Points True False (*) Correct Page 2 of 10 Test: Java Fundamentals Final Exam Review your answers. Multiple windows are used when more than one file is open in the edit area. Refer to Section 4 Lesson 1. feedback. 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 . Section 4 (Answer all questions in this section) 11. An asterisk (*) indicates a correct answer. and question scores below.Help (*) Close Incorrect. 10.

When you open more than one file in Eclipse the system will __________________. 12. The following defines an import keyword: Mark for Review (1) Points Defines where this class lives relative to other classes. Refer to Section 4 Lesson 1.None of the above Incorrect. None of the above. and provides a level of access control. Mark for Review (1) Points Close the previously opened file. 13. Refer to Section 4 Lesson 1. (*) . (*) Put the new file opened in a View area only. Provides the compiler information that identifies outside classes used within the current class. Incorrect. Use tabs to display all files open.

a package. Section 5 (Answer all questions in this section) 15. They allow for repeating code until a certain argument is met. Contains classes that define objects.Precedes the name of the class. Refer to Section 4 Lesson 2. static methods. Incorrect. Refer to Section 4 Lesson 2. None of the above. and classes that define objects. . They allow for repeating code a variable number of times. (*) Contains a main method. Which of the following defines an object class? Mark for Review (1) Points Contains a main method and other static methods. Why are loops useful? Mark for Review (1) Points They save programmers from having to rewrite code. 14. Incorrect.

All of the above. feedback. Refer to Section 5 Lesson 2. In a for loop the counter is not automatically incremented after each loop iteration. True or false? Mark for Review (1) Points True (*) . Code must be written to increment the counter. An asterisk (*) indicates a correct answer. 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. and question scores below. (*) Incorrect. Section 5 (Answer all questions in this section) 16 . Page 3 of 10 Test: Java Fundamentals Final Exam Review your answers. Refer to Section 5 Lesson 2. 17 .

print( (gender == "female") ? "Ms." : "Ms.out. Correct 19 ." : "Ms."). (1) Points System.").out. (*) (gender == "female") ? "Mr. How would you use the ternary operator to rewrite this if statement? if (gender == "female") System." : "Mr.out. char. but not limited to." ). and String. switch statements work on all input types including. True or false? Mark for Review (1) Points . Mark for Review else System." ." . int. (gender == "female") ? "Ms.print("Mr. System.False Correct 18 ." : "Mr.print( (gender == "female") ? "Mr." ).out.print("Ms.

feedback.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. Suppose you misspell a method name when you call it in your program. and question scores below. Section 6 (Answer all questions in this section) 21. Page 4 of 10 Test: Java Fundamentals Final Exam Review your answers. Which of the following explains why this gives you an exception? Mark for Review (1) Points . An asterisk (*) indicates a correct answer.

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. Refer to Section 6 Lesson 2. Because the interpreter does not recognize this method since it was never initialized. 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. it will give you an error when the program is compiled. (*) Incorrect. Refer to Section 6 Lesson 3. Because the parameters of the method were not met. . This will not give you an exception.

Big-O Notation is used in Computer Science to describe the performance of Sorts and Searches on arrays. which makes the algorithm more error prone. which is inefficient on large data sets. which is inefficient on large data sets. It is never inefficient. (*) It involves looping through the array multiple times before finding the value. It requires incrementing through the entire array in the worst case. and repeating these steps for the remainder of . Why might a sequential search be inefficient? Mark for Review (1) Points It utilizes the "divide and conquer" method. Refer to Section 6 Lesson 2. 24. True or false? Mark for Review (1) Points True (*) False Incorrect. Refer to Section 6 Lesson 2.23. Selection sort is a sorting algorithm that involves finding the minimum value in the list. Incorrect. swapping it with the value in the first position. 25.

String[] words={"Oracle". Incorrect."the". String[] word={"Over". . True or false? Mark for Review (1) Points True (*) False Correct Page 5 of 10 Test: Java Fundamentals Final Exam Review your answers. feedback.the list. (*) String[] word=new String[3]. Refer to Section 6 Lesson 1. An asterisk (*) indicates a correct answer. 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]. Section 6 (Answer all questions in this section) 26 . and question scores below."mountain"}."Academy"}].

The following segment of code prints all five of the command line arguments entered into this program. Refer to Section 6 Lesson 1. True or false? Mark for Review (1) Points True False (*) Correct 28 .27 . True or false? int[] q = new int[8]. . The following creates a reference in memory named q that can refer to six different integers via an index. Mark for Review (1) Points True False (*) Incorrect.

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].29 . True or false? Mark for Review (1) Points True False (*) Correct Page 6 of 10 Test: Java Fundamentals Final Exam . Forward thinking helps when creating linear recursive methods. Mark for Review (1) Points True (*) False Correct Section 7 (Answer all questions in this section) 30 .

A static variable is always publicly available.Review your answers. feedback. What do you know for certain? tree. True or false? Mark for Review (1) Points True (*) False Correct 33. The following statement compiles and executes. An asterisk (*) indicates a correct answer. True or false? Mark for Review (1) Points True False (*) Correct 32. Section 7 (Answer all questions in this section) 31. Mark for Review (1) Points numFeet must be an int. and question scores below.grows(numFeet). . There is only one copy a static class variable in the JVM.

True or false? Mark for Review (1) Points True (*) False Incorrect. grows must be the name of an instance field. grows must be the name of a method.tree must be the name of the class. Refer to Section 7 Lesson 1. A constructor is used to create objects. The basic unit of encapsulation in Java is the primitive data type. (*) tree must be a method. True or false? Mark for Review (1) Points True False (*) . 35. 34. Incorrect. Refer to Section 7 Lesson 1.

the memory used by the object is automatically reclaimed. An asterisk (*) indicates a correct answer. 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 . Java's garbage collection is when all references to an object are gone. Section 7 (Answer all questions in this section) 36 . feedback.Correct Page 7 of 10 Test: Java Fundamentals Final Exam Review your answers. and question scores below.

36. } //methods for this class would go here } (1) Points public class driver_class { public static void main(String[] args) { Employee Jane = new Employee("Jane". Employee Brandon = new Employee(). Refer to Section 7 Lesson 1.00). 48. Brandon = new Employee("Brandon". 20.00). 20.00).10 11 (*) Incorrect. public Employee(String n. 35. 36. 48. 48. 38 .00). 35. age = a. } } Incorrect. Refer to Section 7 Lesson 1. 20. The Employee class is below.00). Identify the driver class that correctly initializes employees Jane and Brandon. Employee("Brandon". private int age. int a. private double salary. double s) { name = n. } } public class driver_class { public Employee{ Jane = new Employee("Jane". } } public class Employee { public class driver-class{ Employee Jane = new Employee().00). 36. 35. salary = s. } } (*) public class driver_class { public static void main(String[] args) { Employee("Jane". Employee Brandon = new Employee("Brandon". Mark for Review public class Employee { private String name. .

39 . 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. 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. (*) Having more than one constructor with different names and the same arguments.

(*) A way to call a method with a variable number of arguments using an elipse. and question scores below. Identify the error(s) in the class below. Incorrect. Page 8 of 10 Test: Java Fundamentals Final Exam Review your answers. A type of access specifier that only allows access from inside the same class. Which of the following is the definition of a constructor? Mark for Review (1) Points A keyword that specifies accessibility of code. Refer to Section 7 Lesson 2. Section 7 (Answer all questions in this section) 41 . . A special method that is used to assign initial values to instance variables in a class. feedback. Incorrect.A variable argument method that returns an array. Refer to Section 7 Lesson 2. Choose all that apply. A variable in a method declaration that gets passed into the method. An asterisk (*) indicates a correct answer. 42 .

8. 11000005). counter(int[] numbers). Private cannot be used as an access modifier. 43 . The parameters must be the same for all methods with the same name. int b). Refer to Section 7 Lesson 2. (*) Two methods cannot have the same name. counter(1. (*) . 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. Final cannot be used as an access modifier. 17.Mark for Review (1) Points (Choose all correct answers) No method named min is defined. 5. Incorrect.

counter("one". 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. Refer to Section 7 Lesson 4."two". 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. (*) . 44 .String[] nums). Refer to Section 7 Lesson 2. 45 . Incorrect. Incorrect.

Incorrect. 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. A programming philosophy that promotes protecting data and hiding implementation in order to preserve the integrity of data and methods. An asterisk (*) indicates a correct answer. It is possible to extend more than one class at a time. feedback. . Page 9 of 10 Test: Java Fundamentals Final Exam Review your answers. and question scores below. It restricts access to a specified segment of code. Refer to Section 7 Lesson 4. Section 7 (Answer all questions in this section) 46 . (*) Because the computer cannot handle code that complex.A programming philosophy that promotes simpler. more efficient coding by using exiting code for new applications. To prevent confusion for the programmer.

what would be the result of printing? Mark for Review (1) Points It would print the array one element at a time. (*) The super constructor does not need to be called inside the subclass. Refer to Section 7 Lesson 4. Refer to Section 7 Lesson 4. 47 . The console screen would display: 0 18 215 64 . The first line of the constructor in the subclass.Incorrect. Inside the main method of the subclass. Incorrect. Where should the constructor for a superclass be called? Mark for Review (1) Points Anywhere inside the subclass. 48 . The last line in the constructor of the subclass. If we override the toString() method with the code below.

(*) They must be overridden in a non-abstract subclass. . The console screen would display: [0. (*) They may contain implementation.] (*) It would print the array backwards. 11.18. 49 .64. (*) They must be declared in an abstract class. The console screen would display: {0. The console screen would display: 42 11 64 215 18 0 It would print the string returned from the method. 18. Which of the following are true about abstract methods? Mark for Review (1) Points (Choose all correct answers) They cannot have a method body. Refer to Section 7 Lesson 5.11 42 It would print the string returned from the method. 42} Incorrect. 215. They must be overloaded.215.42.11. 64.

Incorrect. Refer to Section 7 Lesson 5. Refer to Section 7 Lesson 5. Page 10 of 10 . True or false? Mark for Review (1) Points True False (*) Incorrect. Abstract classes can be instantiated. 50 .