Defining Classes II Class Notes, Introduction of Computer Programming | CSC 3405, Study notes of Computer Science

Material Type: Notes; Professor: Wei; Class: Intro Computer Programming; Subject: Computer Science; University: Saint Joseph's University; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 08/16/2009

koofers-user-r7o
koofers-user-r7o 🇺🇸

1

(1)

10 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Chapter 5
Defining Classes II
 Multiple ChoiceMultiple Choice
1) A static method is one that can be used with a _____________.
(a) instance variable
(b) local variable
(c) global variable
(d) the class name as a calling object
2) Static variables are often used:
(a) in arithmetic expressions
(b) to communicate between objects
(c) within looping structures
(d) all of the above
3) Only ______ copy/copies of a static variable are available to objects of a class.
(a) one
(b) two
(c) three
(d) none of the above
4) All of these are methods of Java’s Math class except:
(a) pow
(b) min
pf3
pf4
pf5

Partial preview of the text

Download Defining Classes II Class Notes, Introduction of Computer Programming | CSC 3405 and more Study notes Computer Science in PDF only on Docsity!

Chapter 5

Defining Classes II

 Multiple Choice

  1. A static method is one that can be used with a _____________. (a) instance variable (b) local variable (c) global variable (d) the class name as a calling object
  2. Static variables are often used: (a) in arithmetic expressions (b) to communicate between objects (c) within looping structures (d) all of the above
  3. Only ______ copy/copies of a static variable are available to objects of a class. (a) one (b) two (c) three (d) none of the above
  4. All of these are methods of Java’s Math class except: (a) pow (b) min

(c) random (d) toString

  1. The Math method that returns the nearest whole number that is greater than or equal to its argument is: (a) round (b) ceil (c) floor (d) all of the above
  2. All of the following are wrapper classes except: (a) String (b) Integer (c) Character (d) Double
  3. Converting from a value of primitive type to a corresponding object of its associated wrapper class is called: (a) Boxing (b) Unboxing (c) Converting (d) Reinstantiating
  4. The conversion from an object of a wrapper class to a value of its associated primitive type is called: (a) Boxing (b) Unboxing (c) Converting
  1. A copy constructor has _________ parameters. (a) zero (b) one (c) two (d) three
  2. A condition that allows a programmer to circumvent the private modifier and change the private instance variable is called: (a) a copy constructor (b) a privacy leak (c) a class invariant (d) an anonymous object
  3. A class that contains public methods that can change the data in the object of a class is called a/an: (a) mutable class (b) immutable class (c) invariant class (d) none of the above
  4. To create a package, you must add a package statement at the ____________ of each class file. (a) beginning (b) end (c) before each method signature (d) after the import statements
  5. The program included in the Java SDK that allows a programmer to separate the class interface from the class implementation is called:

(a) javac (b) java (c) javadoc (d) none of the above

  1. Javadoc requires a comment to be delimited by _________ to be included in the extracted class interface. (a) // // (b) /* / (c) /* */ (d) “ “

 True/False

  1. In a static method, you may use the this parameter either explicitly or implicitly.
  2. A main method can be placed inside a class definition.
  3. You may use methods of the Math class without an import statement.
  4. Wrapper classes provide a class type corresponding to each of the primitive types so that you can have class types that behave somewhat like primitive types.
  5. All versions of Java support automatic boxing.
  6. Wrapper classes are provided for all primitive Java types except Boolean.
  7. A bit may have the value of either a 1 or 0.
  8. Primitive types are reference types.
  9. A class invariant is a statement that is always true for every object of the class.
  10. You should avoid the use of null as an argument to a method.
  11. The String class is a mutable class.