ICSI 201 - Chapter 6 Review Questions

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

When a method is overloaded, it means that multiple methods in the same class have the same name, but use different types of parameters. Method overloading is important because sometimes you need several different ways to perform the same operation, so method overloading provides greater flexibility than if it provided only one way to perform every operation.

How does method overloading improve the usefulness of a class?

If a class has a private field, only the class's methods may directly access and make changes to the object's internal data.

If a class has a private field, what has access to the field?

It is a good idea to make a field private because it allows only the class's methods to directly access and make changes to the object's internal data, which protects it from corruption.

Is it a good idea to make a field private? Why or why not?

True

The "new" operator creates an instance of a class. (T/F)

Their parameter lists

Two or more methods in a class may have the same name, as long as this is different.

The only time that Java provides a default constructor is when you do not write your own constructor for a class.

Under what circumstances does Java automatically provide a default constructor for a class?

No-arg constructor.

What do you call a constructor that accepts no arguments?

An accessor method is a method that gets a value from a class's field but does not change it. A mutator method is a method that stores a value in a field or changes the value of a field in some other way.

What is an accessor method? What is a mutator method?

A class is a blueprint or a representation of how an object has to be instantiated. The instance is the actual object created from the class at runtime.

What is the difference between a class and an instance of a class?

Blueprint

A class is analogous to a(n) ______.

False

A class may not have more than one constructor. (T/F)

Things the class knows and actions the class performs.

A class's responsibilities are ______.

Classes are analogous to the blueprint of the houses.

A contractor uses a blueprint to build a set of identical houses. Are classes analogous to the blueprint or the houses?

Instance of a class

An object is a(n) ______.

True

Each instance of a class has its own set of instance fields. (T/F)

Binding

The process of matching a method call with the correct method is known as ______.

Field

This is a class member that holds data.

Class

This is a collection of programming statements that specify the fields and methods that a particular type of object may have.

Accessor

This is a method that gets a value from a class's field, but does not change it.

Constructor

This is a method that is automatically called when an instance of a class is created.

Mutator

This is a method that stores a value in a field or in some other way changes the value of a field.

Default Constructor

This is automatically provided for a class if you do not write one yourself.

new

This key word causes an object to be created in memory.

False

To find the classes needed for an object-oriented application, you identify all the verbs in a description of the problem domain. (T/F)

It creates a new instance of an object or class; it is also used to create an array.

What is the purpose of the "new" key word?

Shadows

When a local variable has the same name as a field, the local variable's name does this to the field's name.

You can have two methods of the same name so long as they have different signatures—this is called method overloading. The methods also have to return the same type of object, and have the same access modifier.

When the same name is used for two or more methods in the same class, how does Java tell them apart?

Stale

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?

False

When you write a constructor for a class, it still has the default constructor that Java automatically provides. (T/F)

Constructors are a special type of method that is used to initialize the object. A constructor is invoked at the time of object creation. It constructs the values (i.e., provides data for the object).

Why are constructors useful for performing "start-up" operations?


Set pelajaran terkait

Government Test Chapters 5, 6, and 7

View Set

French Revolution: Chapter 7: Toward a New Government

View Set

INTRODUÇÃO AO ESTUDO DO DIREITO

View Set

Wireless Network Components & Standards

View Set

CH27 - Client Safety and Security

View Set

Chapter 5 Homework - Financial Management

View Set