Professional Documents
Culture Documents
PDF Test Jfo Java Foundations Final Exam - Compress
PDF Test Jfo Java Foundations Final Exam - Compress
(1) Points
A while loop boolean expression is made up of a counter, increment, and
test.
A counter (i) is declared and initialized inside the while loop.
The counter which gets incremented determines the number of loop
iterations is within the parentheses of a while loop.
The boolean expression that determines the number of loop iterations is
within the parentheses of a while loop. (*)
Correct
(1) Points
The body of a while loop eventually must make the condition false to
avoid infinite loop.
An infinite loop is a code which will execute until the user interrupts the
program
An infinite loop is a commonly the result of a syntax error. (*)
An infinite loop is generally caused by a programming mistake.
Correct
3. A post-test
of the loop evaluates its condition at the end of the loop instead
beginning.
Mark for Review
(1) Points
True (*)
False
Correct
(1) Points
continue
catch
break (*)
switch
Correct
(1) Points
True (*)
False
Correct
(1) Points
switch (*)
for
do-while
while
Correct
(1) Points
True
False (*)
Correct
(1) Points
True (*)
False
Correct
(1) Points
True (*)
False
Correct
Section 7
(1) Points
A public variable.
A static variable. (*)
A local variable.
A private variable.
Correct
11. Static variables of a class can be accessed, even if the class has not
been instantiated.
Mark for Review
(1) Points
True (*)
False
Correct
12. When you write your own constructor, the default constructor is no
longer available.
Mark for Review
(1) Points
True (*)
False
Correct
13. How could you write the Employee constructor so that its parameters
are named the same as the fields they’re initializing?
(1) Points
public Employee(String name, double salary){
name = name;
salary = salary;
}
public
name Employee(String
= this.name; name, double salary){
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) Points
A constructor method may return a value.(*)
15. How would you instantiate the Employee class from a main method
located in another class?
(1) Points
Employee emp1 = new Employee();
Employee emp1 = new Employee(50000);
Employee emp1 = new Employee(50000, "Syam");
Employee emp1 = new Employee("Syam", 50000); (*)
Correct
(1) Points
boolean
int
String (*)
double
Correct
(1) Points
An object can access another object’s public methods.(*)
(1) Points
A technique for including primitives within an ArrayList.
A technique for writing more than one main method.
A technique for limiting one class’s visibility to another. (*)
A technique for debugging.
Correct
(1) Points
True (*)
False
Correct
20. How would you complete this code so that one add method calls the
(1) Points
return add(a, b, 0); (*)
return add(a, b, c);
return (a, b, c);
return (a, b);
Correct
(1) Points
Order of parameters.(*)
Types of parameters.(*)
Number of parameters.(*)
(1) Points
True (*)
False
Correct
(1) Points
Pass a variable as an argument to the method.
Use a return statement and define the method’s return type as non-
void (*)
Define a variable as a field member of the method
Define the method return type as void
Correct
(1) Points
True
False (*)
Correct
25. Which two statements are true about the main method?
Mark for Review
(1) Points
The main method should be able to freely manipulate an object’s fields.
The main method should store the properties and behaviors of objects.
Correct
(1) Points
address
store
memory
new (*)
Correct
(1) Points
True (*)
False
Correct
(1) Points
True (*)
False
Correct
Section 8
(1) Points
True (*)
False
Correct
(1) Points
True (*)
False
Correct
Section 8
(1) Points
repeat loop
do while loop
while loop
for loop (*)
Correct
(1) Points
hai hai (*)
hai
12
hai hai hai
Correct
(1) Points
123
012345
12345
01234 (*)
Correct
(1) Points
True (*)
False
Correct
(1) Points
True (*)
False
Correct
(1) Points
String (*)
Boolean
Byte
Integer
Correct
37. How could you declare an ArrayList so that it can store true or false
values?
Mark for Review
(1) Points
ArrayList<boolean> arrList = new ArrayList<>();
ArrayList<Boolean> arrList = new ArrayList<>(); (*)
ArrayList<true, false> arrList = new ArrayList<>();
ArrayList<True, False> arrList = new ArrayList<>();
Correct
(1) Points
float(*)
Integer
String
int(*)
Correct
39. Using the NetBeans debugger, you can set breakpoints and trace
through a program one line at a time.
Mark for Review
(1) Points
True (*)
False
Correct
(1) Points
A semi-colon is missing.
A datatype is incorrect. (*)
A variable name is misspelled.
(1) Points
int y;
y++; (*)
y = 3 + * 5;
x = ( 3 + 5;
int x=2
Correct
(1) Points
Too many print statements lead to information overload.(*)
Section 9
(1) Points
Rectangle rect = Rectangle(20, 20, 100, 200);
Rectangle rect = new Rectangle(20, 20);
Rectangle rect = new Rectangle(20, 20, 100, 200); (*)
Rectangle rect = new Rectangle(20, 20, 100);
Correct
44. How would you create a custom color that is pure cyan (equal parts
green and blue)?
Mark for Review
(1) Points
Color customColor = Color.rgb(0, 255, 0);
Color customColor = Color.rgb(0, 0, 255);
Color customColor = Color.rgb(255, 255, 0);
Color customColor = Color.rgb(0, 255, 255); (*)
Correct
45. JavaFX doesn’t provide you with UI elements, shapes and text. So
you must always create your own graphics.
Mark for Review
(1) Points
True
False (*)
Correct
(1) Points
True (*)
False
Correct
(1) Points
setOnMouseDragged()
setOnMouseMoved()
setOnMouseReleased()
setOnMouseClicked()
Correct (*)
(1) Points
True (*)
False
Correct
(1) Points
Button
Object (*)
ScrollBar
ImageView
Correct
50. The start() method is the entry point for all JavaFX applications.
Mark for Review
(1) Points
True (*)
False
Correct