Professional Documents
Culture Documents
(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 loop evaluates its condition at the end of the loop instead
of the beginning.
Mark for Review
(1) Points
True (*)
False
Correct
(1) Points
True (*)
False
Correct
6. Which is not a looping statement in Java?
Mark for Review
(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
(Answer all questions in this section)
10. If you need to make a particular variable belong to a class rather
than any individual instance, what type of variable should you use?
Mark for Review
(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 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) 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
16. Which has a default value of null?
Mark for Review
(1) Points
boolean
int
String (*)
double
Correct
(1) Points
An object can access another object’s public methods.(*)
18. What is encapsulation?
Mark for Review
(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
other add method?
public int add(int a, int b, int c) {
return(a+b+c);
}
public int add(int a, int b){
//Complete this line.
}
Mark for Review
(1) Points
return add(a, b, 0); (*)
return add(a, b, c);
return (a, b, c);
return (a, b);
Correct
21. Which three can vary in overloaded methods?
Mark for Review
(1) Points
Order of parameters.(*)
Types of parameters.(*)
Number of parameters.(*)
(1) Points
True (*)
False
Correct
(1) Points
True
False (*)
Correct
(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
26. Which keyword is used to allocate memory for a newly created
object?
Mark for Review
(1) Points
address
store
memory
new (*)
Correct
27. Java developers don't need to know an object’s location in memory.
Mark for Review
(1) Points
True (*)
False
Correct
(1) Points
True (*)
False
Correct
Section 8
(Answer all questions in this section)
29. Each catch block is an exception handler that handles the type of
exception indicated by its argument.
Mark for Review
(1) Points
True (*)
False
Correct
(1) Points
True (*)
False
Correct
Section 8
(Answer all questions in this section)
31. Which loop type is specially designed to traverse an array?
Mark for Review
(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
36. Which of the following is not a wrapper class?
Mark for Review
(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.
A variable hasn’t been assigned a value.
Correct
41. Which is not a compilation error?
Mark for Review
(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.(*)
(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
(1) Points
True
False (*)
Correct
46. An Image is an object that describes the location of a graphics file.
Mark for Review
(1) Points
True (*)
False
Correct
(1) Points
setOnMouseDragged()
setOnMouseMoved()
setOnMouseReleased()
setOnMouseClicked() (*)
Correct
48. JavaFX is used to create GUI applications.
Mark for Review
(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