Computer Programming Test #2

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which symbol indicates that a member is public in a UML diagram? a) # b) + c) * d) -

+

Which symbol indicates that a member is private a UML diagram? a) * b) + c) - d) #

-

A method that gets a value from a class's field but does not change it is known as a mutator method. a) True b) False

False

The public access specifier for a field indicates that the field may not be accessed by statements outside the class. a) True b) False

False

The term "default constructor" is applied to the first constructor written by the author of the class. a) True b) False

False

When a local variable in an instance method has the same name as an instance field, the instance field hides the local variable. a) True b) False

False

For the following code, which statement is not true? public class Circle { private double radius;public double x;private double y; } a) The radius field is not available to code written outside the Circle class. b) The x field is available to code that is written outside the Circle class. c) The radius, x, and y fields are members of the Circle class. d) The y field is available to code written outside the Circle class.

The y field is available to code written outside the Circle class.

For the following code, which statement is not true? public class Sphere { private double radius;public double x;private double y;private double z; } a) The x field is available to code that is written outside the Sphere class. b) The z field is available to code written outside the Sphere class. c) The radius, x, y, and z fields are members of the Sphere class. d) The radius field is not available to code written outside the Sphere class.

The z field is available to code written outside the Sphere class.

"Shadowing" is the term used to describe how the field name is hidden by the name of a local or parameter variable. a) True b) False

True

A constructor is a method that is automatically called when an object is created. a) True b) False

True

A method that stores a value in a class's field or in some other way changes the value of a field is known as a mutator method. a) True b) False

True

An access specifier indicates how a class may be accessed. a) True b) False

True

Each instance of a class has its own set of instance fields. a) True b) False

True

The java.lang package is automatically imported into all Java programs. a) True b) False

True

The term "no-arg constructor" is applied to any constructor that does not accept arguments. a) True b) False

True

What does the following UML diagram entry mean? + setHeight(h : double) : void a) a public field called Height that is a double data type b) a public method with a parameter of data type double that does not return a value c) a private field called setHeight that is a double data type d) a private method with no parameters that returns a double data type

a public method with a parameter of data type double that does not return a value

What is the following statement an example of? import java.util.*; a) an explicit import statement b) a wildcard import statement c) a conditional import statement d) an unconditional import statement

a wildcard import statement

What is the following statement an example of? import java.util.Scanner; a) an explicit import statement b) a wildcard import statement c) a conditional import statement d) an unconditional import statement

an explicit import statement

Which of the following is not involved in identifying the classes to be used when developing an object-oriented application? a) Refine the list of nouns to include only those relevant to the problem. b) Write the code. c) Describe the problem domain. d) Identify all the nouns.

b) Write the code.

If you do not provide initialization values for a class's numeric fields, they will a) cause a compiler error b) cause a runtime error c) be automatically initialized to 0 d) contain an unknown value

be automatically initialized to 0

A class's responsibilities include a) the things a class is responsible for doing b) neither of these c) both of these d) the things a class is responsible for knowing

both of these

After the header, the body of the method appears inside a set of a) parentheses, ( ) b) brackets, [ ] c) braces, { } d) double quotes, " "

braces, {}

One or more objects may be created from a(n) a) method b) instance c) field d) class

class

The key word new a) creates a new variable in memory b) creates a new Java byte code file c)creates a new class d) creates an object in memory

creates an object in memory

It is common practice in object-oriented programming to make all of a class's a) methods private b) fields public c) fields and methods public d) fields private

fields private

A constructor 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

has the same name as the class

Another term for an object of a class is a(n) a) access specifier b) member c) method d) instance

instance

When an object is created, the attributes associated with the object are called a) class instances b) fixed attributes c) instance methods d) instance fields

instance fields

Methods that operate on an object's fields are called a) instance methods b) private methods c) instance variables d) public methods

instance methods

A method a) may have zero or more parameters b) must have at least two parameter variables c) may not have only one parameter variable d) never has parameter variables

may have zero or more parameters

Class objects normally have __________ that perform useful operations on their data, but primitive variables do not. a) methods b) instances c) relationships d) fields

methods

UML diagrams do not contain a) fields b) object names c) methods d) class names

object names

Using the blueprint/house analogy, you can think of a class as a blueprint that describes a house and __________ as instances of the house built from the blueprint. a) methods b) objects c) attributes d) fields

objects

A group of related classes is called a(n) a) attachment b) archive c) collections d) package

package

A constructor is a method that a) removes the object from memory b) returns an object of the class c) never receives any arguments d) performs initialization or setup operations

performs initialization or setup operations

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) stale b) moldy c) asynchronous d) bitter

stale

The scope of a local variable is a) the method in which it is defined b) inside the parentheses of a method header c) the entire class d) inside the class but not inside any method

the method in which it is defined

When an argument is passed by value a) the parameter variable holds the address of the argument b) the parameter variable holds a copy of the value passed to it c) changes can be made to the argument variable d) the parameter variable cannot be changed

the parameter variable holds the address of the argument

To indicate the data type of a variable in a UML diagram you specify a) the data type followed by the variable name b) the class name followed by the variable name followed by the data type c) the variable name followed by a colon and the data type d) the variable name followed by the data type

the variable name followed by a colon and the data type

Data hiding (which means that critical data stored inside the object is protected from code outside the object) is accomplished in Java by a) using the private access specifier on the class fields b) using the private access specifier on the class definition c) using the private access specifier on the class methods d) using the public access specifier on the class methods

using the private access specifier on the class fields


Kaugnay na mga set ng pag-aaral

Exam 1 Development and Mobility

View Set

4. Specific Behavior Change Procedures

View Set

Consumer Purchasing and Wise Buying Strategies

View Set

nclex GU, Pediatric GU questions Nclex, renal gu nclex, Renal & GU- NCLEX, GU NCLEX 3500, NCLEX GU

View Set

BIOL21403: Marine Ecology and Physiology

View Set

Communication Entrance Practice Exam

View Set