Java Chapter 6

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

has the same name as the class

A constructor ________. Multiple Choice: 1) has the return type of void 2) always has a private access specifier 3) has the same name as the class 4) always accepts two arguments

performs initialization or setup operations

A constructor is a method that ________. Multiple Choice: 1) removes the object from memory 2) performs initialization or setup operations 3) never receives any arguments 4) returns an object of the class

memory address

A reference variable stores a(n) ________. Multiple Choice: 1) binary encoded decimal 2) string 3) object 4) memory address

instance

Another term for an object of a class is a(n) ________. Multiple Choice: 1) access specifier 2) instance 3) member 4) method

methods

Class objects normally have ________ that perform useful operations on their data, but primitive variables do not. Multiple Choice: 1) fields 2) relationships 3) instances 4) methods

using the private access specifier on the class fields

Data hiding (which means that critical data stored inside the object is protected from code outside the object) is accomplished in Java by ________. Multiple Choice: 1) using the public access specifier on the class methods 2) using the private access specifier on the class definition 3) using the private access specifier on the class methods 4) using the private access specifier on the class fields

The z field is available to code written outside the Sphere 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; } Multiple Choice: 1) The radius field is not available to code written outside the Sphere class. 2) The z field is available to code written outside the Sphere class. 3) The x field is available to code that is written outside the Sphere class. 4) The radius, x, y, and z fields are members of the Sphere class.

fields private

It is common practice in object-oriented programming to make all of a class's ________. Multiple Choice: 1) fields private 2) methods private 3) fields public 4) fields and methods public

class

One or more objects may be created from a(n) ________. Multiple Choice: 1) method 2) class 3) instance 4) field

the instance methods of the same class

The scope of a private instance field is ________. Multiple Choice: 1) the method in which it is defined 2) the instance methods of the same class 3) inside the parentheses of a method header 4) inside the class but not inside any method in that class

they have different parameter lists

Two or more methods in a class may have the same name as long as ________. Multiple Choice: 1) they have different return types but the same parameter list 2) they have different return types 3) they have different parameter lists 4) You cannot have two methods with the same name.

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

What does the following UML diagram entry mean? + setHeight(h : double) : void Multiple Choice: 1) a private field called setHeight that is a double data type 2) a public field called setHeight that is a double data type 3) a private method with no parameters that returns a double data type 4) a public method with a parameter of data type double that does not return a vaterm-2lue

instance fields

When an object is created, the attributes associated with the object are called ________. Multiple Choice: 1) fixed attributes 2) instance methods 3) instance fields 4) class instances

the object's memory address

When an object is passed as an argument to a method, what is passed into the method's parameter variable? Multiple Choice: 1) the values for each field 2) the object's memory address 3) the class name 4) the method names

Encapsulation

________ refers to combining data and code into a single object. Multiple Choice: 1) The constructor 2) Data hiding 3) Encapsulation 4) Abstraction


Kaugnay na mga set ng pag-aaral

RCH Melb - Febrile seizure guideline

View Set

NCLEX Review Study Guide (Summer 2022)

View Set

Computing Essentials Practice Exam 2

View Set