1 . Match each of the following literals ('x', 10, 10.2, 100L, "hello") with its respective data type.
Mark for Review (1) Points
char, int, double, long, String (*)
boolean, byte, int, long, Short
char, int, long, float, String
char, boolean, float, long, String
char, double, int, long, String
Incorrect. Refer to Section 4 Lesson 3.
2 . Which of the following is the name of a Java primitive data type?
Mark for Review (1) Points
Object
Rectangle
double (*)
String
Incorrect. Refer to Section 4 Lesson 3.
3 . Which of the following defines an object class?
Mark for Review (1) Points
Contains a main method and other static methods.
Contains classes that define objects. (*)
Contains a main method, a package, static methods, and classes that define objects.
None of the above.
Incorrect. Refer to Section 4 Lesson 2.
4 . Which of the two diagrams below illustrate the general form of a Java program?
Mark for Review (1) Points
Example A
Example B (*)
Incorrect. Refer to Section 4 Lesson 2.
5 . The == operator tests if two String references are pointing to the same String object. True or false?
Mark for Review (1) Points
True (*)
False
Incorrect. Refer to Section 4 Lesson 4. 6 . The followin g code is an example of creating a String reference :
String s;
True or false?
Mark for Review (1) Points
True (*)
False
Incorrect. Refer to Section 4 Lesson 4.
7. Given the code
String s1 = "abcdef"; String s2 = "abcdef"; String s3 = new String(s1);
Which of the following would equate to false?
Mark for Review (1) Points
s1 == s2
s1 = s2
s3 == s1 (*)
s1.equals(s2)
s3.equals(s1)
Correct
8. Consider the following code snippet.
What is printed?
Mark for Review (1) Points
0
1 (*)
2
11
12
Incorrect. Refer to Section 4 Lesson 4.
9. 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
Incorrect. Refer to Section 4 Lesson 4.
10. A workspace is:
Mark for Review (1) Points
The physical location onto which you will store and save your files.
The location where all projects are developed and modified.
The location where you can have one or more stored perspectives.
All of the above. (*)
Incorrect. Refer to Section 4 Lesson 1. 11. A perspective is described as: Mark for Review (1) Points
A combination of views and editors (*)
A combination of views and windows
A combination of editor tabs
None of the above
Correct
12. When you open more than one file in Eclipse the system will __________________.
Mark for Review (1) Points
Close the previously opened file.
Use tabs to display all files open. (*)
Put the new file opened in a View area only.
None of the above.
Incorrect. Refer to Section 4 Lesson 1.
13. What symbols are required for a compiler to ignore a comment?
Mark for Review (1) Points
// (*)
/*
*/
/*/
Incorrect. Refer to Section 4 Lesson 1.
14. A combination of views and editors are referred to as _______________.
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. 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 (*)
Incorrect. Refer to Section 5 Lesson 1.
16. switch statements work on all input types including, but not limited to, int, char, and String. True or false?
Mark for Review (1) Points
True
False (*)
Correct
17. The three logic operators in Java are:
Mark for Review (1) Points
&&, ||, ! (*)
!=,=,==
&&,!=,=
&,|,=
Correct
18. Which of the following is true about a do-while loop?
Mark for Review (1) Points
It is a post-test loop.
It is a modified while loop that allows the program to run through the loop once before testing the boolean condition.
It continues looping until the condition becomes false.
All of the above. (*)
Incorrect. Refer to Section 5 Lesson 2.
19. 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
20. In the code fragment below, the syntax for the for loop's initialization is correct. True or false?
public class ForLoop { public static void main (String args[]) { for ((int 1=10) (i<20) (i++))<br> {System.out.Println ("i: "+i); } } }
Mark for Review (1) Points
True
False (*)
Incorrect. Refer to Section 5 Lesson 2.
21. 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} (*)
Correct
22. Selection sort is efficient for large arrays. True or
Mark for Review
false? (1) Points
True
False (*)
Incorrect. Refer to Section 6 Lesson 2.
23. 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.
24. Why might a sequential search be inefficient?
Mark for Review (1) Points
It utilizes the "divide and conquer" method, which makes the algorithm more error prone.
It requires incrementing through the entire array in the worst case, which is inefficient on large data sets. (*)
It involves looping through the array multiple times before finding the value, which is inefficient on large data sets.
It is never inefficient.
Incorrect. Refer to Section 6 Lesson 2.
25. 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];
String[] name=new Strings[8];
String[] names=new String[8]; (*)
String[] name=String[8];
Incorrect. Refer to Section 6 Lesson 1. 26Which of Mark for
. 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];
String[] word={"Over","the","mountain"}; (*)
String[] word=new String[3];
String[] words={"Oracle","Academy"}];
Incorrect. Refer to Section 6 Lesson 1.
27. The following array declaration is valid. True or false?
int k[] = new int[10];
Mark for Review (1) Points
True (*)
False
Incorrect. Refer to Section 6 Lesson 1.
28. 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
1 0 0 0 1 0
0 0 1
1 0 0 1 1 0 1 1 1 (*)
0 0 1 0 1 0 1 0 0
Correct
29. 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
Incorrect. Refer to Section 6 Lesson 3.
Section 7 (Answer all questions in this section)
30. The following statement compiles and executes. What do you know for certain?
tree.grows(numFeet);
Mark for Review (1) Points
numFeet must be an int.
tree must be the name of the class.
grows must be the name of an instance field.
grows must be the name of a method. (*)
tree must be a method.
Correct 3 1. The basic unit of encapsulat ion in Java is the primitive data type. True or false? Mark for Review (1) Points
True
False (*)
Correct
32. Instance variable names may only contain letters and digits. True or false?
Mark for Review (1) Points
True
False (*)
Incorrect. Refer to Section 7 Lesson 1.
33. A class can only have one constructor. True or false?
Mark for Review (1) Points
True
False (*)
Incorrect. Refer to Section 7 Lesson 1.
34. 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 method doNothing is: public double doNothing(int n) { n = n + 8; return (double) 12/n; }
Mark for Review (1) Points
1.75, 13
0.571, 21
1.75, 21
0.571, 13 (*)
Incorrect. Refer to Section 7 Lesson 1.
35. What value will return for j when the setValue method is called?
Mark for Review (1) Points
31
32
10
11 (*)
Incorrect. Refer to Section 7 Lesson 1. 36. Static methods can write to class variables. True or false? Mark for Review (1) Points
True (*)
False
Incorrect. Refer to Section 7 Lesson 3.
37. Static methods can read instance variables. True or false?
Mark for Review (1) Points
True
False (*)
Incorrect. Refer to Section 7 Lesson 3.
38. Static methods can't act like "setter" methods. True or false?
Mark for Review (1) Points
True
False (*)
Correct
39. If a class is immutable then it must be abstract. True or false?
Mark for Review (1) Points
True
False (*)
Incorrect. Refer to Section 7 Lesson 5.
40. Which of the following can be declared final?
Mark for Review (1) Points
Classes
Methods
Local variables
Method parameters
All of the above (*)
Incorrect. Refer to Section 7 Lesson 5.
41. Consider the following method of the class Test:
public static List returnList(List list) { return list; }
Which of the following program segments in Test's client class will compile with no errors?
I. List nums = new ArrayList(); nums = Test.returnList(nums); II. ArrayList nums = new ArrayList();
Mark for Review (1) Points
nums = Test.returnList(nums); III. ArrayList nums1 = new ArrayList(); List nums2 = Test.returnList(nums1);
I only I and III (*) II only II and III I, II, and III
Incorrect. Refer to Section 7 Lesson 5.
42. Why are hierarchies useful for inheritance?
Mark for Review (1) Points
They keep track of where you are in your program. They restrict a superclass to only have one subclass. They organize constructors and methods in a simplified fashion. They are used to organize the relationship between a superclass and its subclasses. (*)
Incorrect. Refer to Section 7 Lesson 4.
43. If a variable in a superclass is private, could it be directly accessed or modified by a subclass? Why or why not?
Mark for Review (1) Points
Yes. A subclass inherits full access to all contents of its super class. Yes. Any variable passed through inheritance can be changed, but private methods cannot. No. A private variable can only be modified by the same class with which it is declared regardless of its inheritance. (*) No. Nothing inherited by the super class can be changed in the subclass.
Correct
44. It is possible for a subclass to be a superclass. True or false?
Mark for Review (1) Points
True (*) False
Incorrect. Refer to Section 7 Lesson 4.
45. If you inherit a class, you do not inherit the class' constructors. True or false?
Mark for Review (1) Points
True (*) False
Correct
4 6. Which of the follow ing is the definit ion for a variabl e argum ent metho d?
Mark for Review (1) Points
A way to create a new class.
Specifies accessibility to code.
Having more than one constructor with the same name but different arguments.
A type of argument that enables calling the same method with a different number of arguments. (*)
Incorrect. Refer to Section 7 Lesson 2.
47. Which of the following is the definition of a constructor?
Mark for Review (1) Points
A keyword that specifies accessibility of code.
A special method that is used to assign initial values to instance
variables in a class. (*)
A way to call a method with a variable number of arguments using an elipse.
A variable in a method declaration that gets passed into the method.
Correct
48. 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.
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

Tidak ada komentar:
Posting Komentar