Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Programming Reviewer

The document contains a series of multiple-choice questions related to Java programming concepts, including variable scope, constructors, method parameters, and control structures. It tests knowledge on topics such as access specifiers, data types, and object-oriented principles. The questions also cover basic programming constructs like loops and method functionality.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Programming Reviewer

The document contains a series of multiple-choice questions related to Java programming concepts, including variable scope, constructors, method parameters, and control structures. It tests knowledge on topics such as access specifiers, data types, and object-oriented principles. The questions also cover basic programming constructs like loops and method functionality.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

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

14. What is a member of a class that holds data? A. method C. field


B. instance D. constructor
15. UML stands for which of the following?
A. Universal Modeling Language C. Unified Modeling Language B. Unified Model Language D.
Unicode Modelling Language
16. What key word causes a value to be sent back from a method to the statement that called
it?
A. send C. value B. return D. public
17. Which method gets a value from a class’s field, but does not change it? A. accessor C. void
B. constructor D. mutator
18. What method stores a value in a field or in some other way changes the value of a field?
A. accessor C. void
B. constructor D. mutator
19. When the value of an item is dependent on other data, and that item is not updated when
the other data is changed, what has the value become?
A. bitter C. asynchronous B. stale D. moldy
20.Which method of a class does not have any return type—not even void? A. accessor C.
mutator
B. void D. constructor 21.What does ASCII stand for?
A. American Symbol Code For Information Interchange
B. American Sales Code For Corrupt Information Interchange C. American Standard Code For
Information Interchange
D. American Standard Code For Informational Interchange
22.A constructor has which of the following?
A. always accepts two arguments
B. has the return type of void
C. has the same name as the class
D. always has a private access specifier
23.The first position in a String? A. position 0
B. position 1
24.What is a return value? A. The value B. The value C. The value D. The value
C. position 2 D. position 3
that a method prints to the screen. that is inputted to a method.
that a user inputs to a program. that a method outputs.
25.If a class is named Student, the class constructor name is? A. Student(0) C. Student(new
Student)
B. Student() D. Student([])

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

25.What output is produced by the following program? public class Nums


{
public static void main(String args[])
{
int x = 15; sentence(x, 45);
int y = x - 5;
sentence(y, x + y);
}
public static void sentence(int num1, int num2) {
System.out.println(num1 + " " + num2);
}
}
A. 15 42 10 25
B. 57 25
C. 25 57
D. num1 num2

You might also like