JFo Java Foundations Final Exam
1. Looping continues as long as the boolean expression in the for loop is false.
benar
Palsu (*)
Correct
(1/1) Point
2. The initialization expression initializes the loop and it is executed only once, as the loop begins.
benar (*)
Palsu
Incorrect. Refer to Section 6 Lesson 1.
(0/1) Point
3. Each expression in the header section of a for loop is optional.
benar (*)
Palsu
Correct
(1/1) Point
4. A for loop is also called a definite loop
benar (*)
Palsu
Incorrect. Refer to Section 6 Lesson 1.
(0/1) Point
5. A continue statement is used to skip the remaining statements in the body of a loop and continue with the next iteration of the loop.
benar (*)
Palsu
Correct
6. The purpose of adding comments is to increase the ability to understand the logic easily.
benar (*)
Palsu
Correct
(1/1) Point
7. Which of the two are pre-test loops?
(Pilih semua jawaban yang benar)
forEach
while (*)
for (*)
do-while
Correct
(1/1) Point
8. A while loop is often used with Scanner input as you don't know many times you'll need to re-prompt the user if they type bad data.
benar (*)
Palsu
Correct
(1/1) Point
9. A pre-test loop evaluates the condition prior to execution of the loop.
benar (*)
Palsu
Correct
(1/1) Point
Section 7
(Jawab semua pertanyaan di bagian ini)
10. You have created an Employee class with all required fields and methods. 10 employees join the company. Should you copy and paste the Employee class for all 10 employees?
benar
Palsu (*)
Correct
11. Variables created within a method can be accessed outside that method.
benar
Palsu (*)
Correct
(1/1) Point
12. Which two statements are true about the main method?
(Pilih semua jawaban yang benar)
The main method should be as simple as possible. (*)
The main method should be able to freely manipulate an object’s fields.
The main method should store the properties and behaviors of objects.
The main method is commonly used to instantiate objects. (*)
Correct
(1/1) Point
13. An object must be instantiated before its non-static fields and methods can be accessed.
benar (*)
Palsu
Correct
(1/1) Point
14. You never need to instantiate a Math object.
benar (*)
Palsu
Correct
(1/1) Point
15. Which two are access modifiers?
(Pilih semua jawaban yang benar)
final
static
public (*)
private (*)
Correct
16. Which two statements are true?
(Pilih semua jawaban yang benar)
An object can access another object’s public fields. (*)
An object can access another object’s public constructor.
An object can access another object’s public methods. (*)
An object can access another object’s main method.
Correct
(1/1) Point
17. What is encapsulation?
A technique for debugging.
A technique for limiting one class’s visibility to another. (*)
A technique for including primitives within an ArrayList.
A technique for writing more than one main method.
Correct
(1/1) Point
18. You can write more than one constructor in a class.
benar (*)
Palsu
Correct
(1/1) Point
19. Which statement is true?
The default constructor can accept arguments.
You must write at least one constructor in your class.
A constructor can be written to accept arguments. (*)
The default constructor is still available when you add your own constructor.
Incorrect. Refer to Section 7 Lesson 4.
(0/1) Point
20. Method overloading can be a useful technique for defining methods with similar functionality or calculations.
benar (*)
Palsu
Correct
21. In this statement, identify the type of the variable s.
Student s = new Student();
String
Class
Student (*)
null
Correct
(1/1) Point
22. Objects are stored within the heap memory.
benar (*)
Palsu
Correct
(1/1) Point
23. Which type of memory is allocated for the code below?
int x = 1;
int y = 2;
x=y;
Stack memory (*)
No memory is allocated
PileDriver memory
Heap memory
Correct
(1/1) Point
24. How could you write the Employee constructor so that its parameters are named the same as the fields they’re initializing?
public class Employee{
private String name;
private double salary;
public Employee(String name, double salary){
//initialize name
//initialize salary
}
}
public Employee(String name, double salary){
name = name;
salary = salary;
}
public Employee(String name, double salary){
name = this.name;
salary = this.salary;
}
public Employee(String name, double salary){
this.name = name;
this.salary = salary;
} (*)
public Employee(String name, double salary){
this.name = this.name;
this.salary = this.salary;
}
Correct
(1/1) Point
25. Which has a default value of null?
boolean
int
String (*)
double
Correct
26. Which two statements are NOT true about constructors?
(Pilih semua jawaban yang benar)
A constructor method may return a value. (*)
A constructor method is called once for each instance of an object.
The constructor method is called during instantiation.
A constructor method has a void return type. (*)
Correct
(1/1) Point
27. How would you instantiate the Employee class from a main method located in another class?
public class Employee{
private String name;
private double salary;
public Employee(String n, double s){
name = n;
salary = s;
}
}
Employee emp1 = new Employee();
Employee emp1 = new Employee(50000);
Employee emp1 = new Employee(50000, "Syam");
Employee emp1 = new Employee("Syam", 50000); (*)
Correct
(1/1) Point
28. A constructor is a special method which is commonly used to set the initial values of an object’s fields.
benar (*)
Palsu
Correct
(1/1) Point
Section 8
(Jawab semua pertanyaan di bagian ini)
29. Runtime errors can be caught by Java’s exception handling mechanism.
benar (*)
Palsu
Correct
(1/1) Point
30. Testing and debugging are important activities in software development.
benar (*)
Palsu
Correct
31. Using a Java debugger, you can set breakpoints and trace through a program one line at a time.
benar (*)
Palsu
Correct
(1/1) Point
32. What are two disadvantages of adding print statements for debugging?
(Pilih semua jawaban yang benar)
Too many print statements lead to information overload. (*)
Print statements cannot print the values of variables.
It’s tedious to remove print statements. (*)
Print statements cannot print the values of an object’s fields.
Correct
(1/1) Point
33. Given:
int x[];
What is the value of x?
Some random number.
0
null (*)
1
Correct
(1/1) Point
34. Arrays are like variables which must be declared prior to use.
benar (*)
Palsu
Correct
(1/1) Point
35. What is the starting index of an array?
0 (*)
You can start with anything
It depends on the type of the array.
1
Correct
36. What is an array?
An array is a way to create multiple copies of a single value.
An array is an indexed container that holds a set of values of a multiple types.
An array is an indexed container that holds a set of values of a single type. (*)
An array is a Java primitive type.
Correct
(1/1) Point
37. Which two cannot be stored in an ArrayList?
(Pilih semua jawaban yang benar)
Integer
float (*)
int (*)
String
Correct
(1/1) Point
38. A wrapper class encapsulates, or wraps, the primitive types within an object.
benar (*)
Palsu
Correct
(1/1) Point
39. Which is not used to traverse an ArrayList?
for-each loop
iterator
ListIterator
do- while loop (*)
Incorrect. Refer to Section 8 Lesson 2.
(0/1) Point
40. How could you declare an ArrayList so that it can store true or false values?
ArrayList<True, False> arrList = new ArrayList<>();
ArrayList<true, false> arrList = new ArrayList<>();
ArrayList<Boolean> arrList = new ArrayList<>(); (*)
ArrayList<boolean> arrList = new ArrayList<>();
Correct
41. Each catch block is an exception handler that handles the type of exception indicated by its argument.
benar (*)
Palsu
Correct
(1/1) Point
42. What happens when you don’t handle an exception?
The execution of the program is terminated abruptly. (*)
The program encounters error and simply ignores it.
A message is printed to the console to ask you how to handle the error.
All of the code after the error is skipped, but the program still runs.
Correct
(1/1) Point
Section 9
(Jawab semua pertanyaan di bagian ini)
43. Which is not a JavaFX Node?
Object (*)
ImageView
ScrollBar
Button
Correct
(1/1) Point
44. A layout Pane dictates how Nodes must be positioned
benar (*)
Palsu
Correct
(1/1) Point
45. Which type of Root Node allows Nodes to be placed anywhere?
Group (*)
StackPane
HBox
TilePane
Correct
46. The JavaFX API contains descriptions of Java FX features.
benar (*)
Palsu
Correct
(1/1) Point
47. Which is the correct syntax to instantiate a JavaFX Rectangle?
Rectangle rect = new Rectangle(20, 20);
Rectangle rect = new Rectangle(20, 20, 100);
Rectangle rect = Rectangle(20, 20, 100, 200, 200);
Rectangle rect = new Rectangle(20, 20, 100, 200); (*)
Correct
(1/1) Point
48. Lambda Expressions provide much more effective and cleaner syntax for working with GUI applications and sorting lists.
benar (*)
Palsu
Correct
(1/1) Point
49. Audio can be played by referencing the AudioClip object directly.
benar (*)
Palsu
Correct
(1/1) Point
50. JavaFX doesn’t provide you with UI elements, shapes and text. So you must always create your own graphics.
benar
Palsu (*)
Correct
Posting Komentar untuk "JFo Java Foundations Final Exam"