Total Pageviews

Friday, May 25, 2012

EXAM 2

View Assessment Result: Exam 2 Multiple-Choice




Upon compilation, the source code of a Java class MyClass will be stored in the file _____, and the corresponding byte code will be stored in the file _____.





(d)

5.00


    See sections 2.1.2 and 2.1.3 in the course notes.

   




Model elements in Java programs that share a common behavior can be grouped into categories called





(b)

5.00


   See Chapter 1, page 3, in the course textbook.

   




In addition to coding, the process of programming model involves which of the following?
  1. Evaluation and testing
  2. Defining and redefining a problem
  3. Planning a solution to a problem






(c)

5.00


    All of these are part of the programming process. See section 2.1.6 in the course notes.

   




Valid Java comments include which of the following?
  1. /* this is an /* embedded */ comment */
  2. /* this is an // embedded // comment */
  3. // this is a comment */






(b)

0.00


   See section 2.1.3, subsections "The Catfish Class," in the course notes.
   




A Java servlet can obtain an object for sending data to the client of the servlet by calling which of the following methods of HttpServletResponse?





(d)

5.00


   See section 2.1.4, subsection "The Welcome Servlet," in the course notes.

   




Which of the statements below correctly constructs an object using the following constructor?
Plane(int a, int b, int c)
{
   // code
}






(c)

5.00


   See sections 2.2.4 and 2.2.6 in the course notes. Refer to the manner in which the constructors for the HtmlPage and AlgaeColony classes are implemented.
   




Which of the following is (are) consistent with Java naming conventions regarding capitalization?
  1. int numPeople;
  2. int Counter;
  3. class serviceElevator{}






(d)

5.00


    See section 2.2.2, subsection "Mapping English Terms to Java Terms," in the course notes.

   




The following line can be the start of
public void paint(Graphics  g)






(a)

5.00


   See section 2.2.2 through 2.2.4 in the course notes.
   




In Java, variables declared in the body of a method are known as _____ variables.





(d)

5.00


   See Chapter 4, page 122, in the course textbook.

   




In Java, non-sequential execution of code is achieved by using _____ statements.





(d)

5.00


    See sections 2.3.4 and 2.3.5 in the course notes.

   




The type of the number 2.0 in Java can be





(d)

5.00


   See section 2.3.1 in the course notes.
   




A Java Virtual Machine (JVM) is





(c)

0.00


    See section 2.1.2 in the course notes.

   




How many times will the following loop execute?
int  i;
for (i = 0; i < 9; i = i + 1)
    i = 8;






(a)

5.00


   See section 2.3.5 of the course notes.
   




Assume you are given a method with a specification double numbers(); that supplies you with numbers from the user's input. You need to find the first input number from user input that is smaller than 0.5 and put it in the variable x. Which of the following can be used for that purpose?
  1. double x = numbers(); while (x <= 0.5) x = numbers();
  2. double x = 0.1; while (x >= 0.5) x = numbers();
  3. double x; for (x = numbers(); x >= 0.5; x = numbers());






(c)

5.00


   The first item sets x to the first number greater than 0.5; the second item never gets user input. See section 2.3.5 of the course notes.

   




In Java, for primitives, the assignment operator is the symbol _____ and the equality operator is the symbol _____.





(a)

5.00


    See sections 2.3.2 and 2.3.3 in the course notes.

   




Consider the following code fragment.
int m = 3;
int n = m / 2;
What is the value of n?






(c)

5.00


   Integer division truncates. See section 2.3.2 in the course notes.
   




If T represents the value true and F represents the value false, what does the following expression evaluate to?

! ( ( T || F ) && !F )






(c)

5.00


   Using the precedence of the operators and the parentheses in the expression, it can be evaluated like this:
 ! ( ( T || F ) && !F ) ! ( ( T ) && T ) ! ( T && T ) ! ( T ) F
See section 2.3.3 in the course notes.

   




In Java, the scope of a parameter of a method contains the scope of which of the following?





(c)

5.00


    See section 2.3.1 in the course notes.

   




In the class defined below
class MyClass {
    int age = 19;
    void myMethod()
    {
        int counter;
    }
}






(c)

5.00


   See section 2.3.1 of the course notes.
   




Which of the following is a method invocation that retrieves the first element from an instance of class java.util.Vector?





(a)

0.00


   See Chapter 9, page 335, in the course textbook.

   



Go to top of assessment.


No comments:

Post a Comment