Programming Reviewer
Programming Reviewer
When a local variable has the same name as a field, what does the local
variable’s name do to the field’s name?
A. shadows C. deletes
B. complements D. merges with
2.If you do not write a constructor for a class, what is automatically provided for the class?
A. accessor method C. default constructor
B. default instance D. predefined constructor
3.String and System classes are what part of this package? A. java.io C. java.lang
B. java.util D. java.net
4.Two or more methods in a class may have the same name, as long as what should be
different?
A. their return values C. their parameter list
B. their access specifier D. their memory address
5.What is the process of matching a method call with the correct method known for?
A. matching C. linking
B. binding D. connecting
6.A class's responsibilities are which of the following? A. the objects created from the class
B. things the class knows
C. actions the class performs D. both b and c
PROGRAMMING 2nd Semester 3rd Quarter
7.Which of the following is the correct syntax for writing a method with parameters?
A. public static void example (x: int, y: int) {} C. public static void example (x, y) {} B. public static
void example (int x, int y) {} D. public static void example (int x,y) {}
8.Why do we use methods in Java programming? A. break down our program into smaller parts
B. make our program more readable
C. avoid repeating code D. all of the above
9.What are parameters?
A. the value that a method returns
B. the type that is given to a variable
C. the values that a method prints to the screen
D. the formal names given to the data/variables that are passed into a method
10.How many characters does ASCII contain? A. 256 C. 128
B. 127 D. 265
11. When this access specifier is applied to a class member, the member cannot be accessed
by code outside the class. What is this access specifier?
A. public C. void
B. private D. protected
12. Which of the following a class is analogous to? A. blueprint C. architect
B. house D. attribute
13. An object is which of the following?
A. blueprint C. variable
B. attribute D. instance
1.What is a structure that can store many of the same kind of data together at once?
A. array C. index B. element D. list
2.Which is a statement that moves program control to the next statement after the current
structure.
A. break C. default B. case D. switch
3.The statement int[] names. What does this do?
A. creates an array C. generates a syntax error
B. declares an array variable D. none of the above
4.Which of the following is NOT a comparison operator in Java language? A. > C. =
B. < D. ==
5.Which Scanner class method is used to read string value from the user? A. next() C.
nextLine()
B. nextString() D. Both A and C
6.What is the general structure of a method?
A. <return value type><method name> (arguments)
B. public static void main (String[ ] args)
C. <modifier><return value type><method name> (parameters) D. <method name> (parameter)
7.What is making an instance of one class a field in another class? A. nesting C. aggregation
B. class fielding D. concatenation
8.The Java Virtual Machine (JVM) periodically performs what process, which automatically
removes unreferenced objects from memory?
A. memory cleansing C. garbage collection B. memory deallocation D. object termination
9.What does CRC stand for?
A. Class, Return Value, Composition
B. Class, Responsibilities, Collaborations C. Class, Responsibilities, Composition D. Compare,
Return, Continue
10.This type of method cannot access any non-static member variable in its own class. What is
this?
A. instance C. void
B. static D. non-static
11. The code between a pair of braces in a method is called? A. block C. private
B. head D. null
12. Which of the following could be the last legally coded line of a method declared as: public
static int getVal(double sum)?
A. return 2.5; C. return;
B. return void; D. return 77;
13.What does void mean?
A. Void means that a method returns any value.
B. Void means that a method takes no parameters.
C. Void means that a method returns no value.
D. Void means that a method can take any parameter.
14. What does this method call return? doubleInt(5);
public int doubleInt(int x)
{
PROGRAMMING 2nd Semester 3rd Quarter
x * 2; }
22.Calculate the expression: (int)(9 % 2 * 7 / 3);
A. 4.67 B. 4
A. 10
B. 5
C. this method returns nothing.
D. this method is improperly written.
15.Which of the following is a false statement?
a. A variable of type int can hold any whole number value from approximately negative two
billion to positive two billion.
b. We can use the data types of byte or short to hold larger values than can be accommodated
by an int.
c. When you assign a value to an int variable, we do not type any commas; we type only digits
and an optional plus or minus sign to indicate a positive or negative integer.
d. none of the above.
16.What kind of loop is the while loop? A. prefix
B. pretest
17.What kind of loop is the for loop? A. prefix
B. pretest
C. postfix D. posttest
C. postfix D. posttest
18.What is a constant that stores a value that is used to signify that a loop should stop iterating
which is also called a flag?
A. accumulator C. meter B. counter D. sentinel
19.What is a variable that is incremented by a fixed value? A. accumulator C. meter
B. counter D. sentinel
20. What kind of loop is the do-while loop?
A. prefix C. postfix
B. pretest D. posttest 21.What is stored in x after the code segment is executed?
int x;
x = 10 + 5 % 3;
A. 0 B. 11
C. 5 D. 12
C. 2.33 D. 2
23.What is the returned value of recMethod(5)? public static int recMethod(int x)
{
if(x==40)
return x;
else
return(x + recMethod(x * 2)); }
A. 68
B. 75
24.What is the output of the code?
C. 70 D. 82
public class Points
{
public static void main(String args[]) {
methodRankPoints(255.7); }
public static void methodRankPoints(double points) {
if (points >= 202.5)
}}
System.out.println("Rank:A1"); else if (points >= 122.4) System.out.println("Rank:A2"); else
System.out.println("Rank:A3");
A. Rank:A1 B. Rank:A2
C. Rank:A3 D. Rank:A4