Module 4 Quiz PDF

Title Module 4 Quiz
Course Java Programming
Institution Miami Dade College
Pages 17
File Size 289 KB
File Type PDF
Total Downloads 97
Total Views 134

Summary

Module 4 Quiz...


Description

Question 1



5 out of 5 points

When a field is declared static there will be Selected Answer:

only one copy of the field in memory. Question 2



5 out of 5 points

A static field is created by placing the key word static Selected Answer:

after the access specifier and before the field's data type. Question 3



5 out of 5 points

The key word this is the name of a reference variable that an object can use to refer to itself. Selected Answer:

Tru e

Question 4



5 out of 5 points

Overloading is Selected Answer:

having two or more methods with the same name but different signatures. Question 5



5 out of 5 points

Given the following method header, what will be returned from the method? public Rectangle getRectangle() Selected Answer:

the address of an object of the Rectangle class Question 6



5 out of 5 points

A declaration for an enumerated type begins with the ________ key word. Selected Answer:

enum

Question 7



5 out of 5 points

When an object is passed as an argument, it is actually a reference to the object that is passed. Selected Answer:



Tru e

Question 8 5 out of 5 points

You cannot use the fully-qualified name of an enum constant for

Selected Answer:

a case expressi on. Question 9



5 out of 5 points

An instance of a class does not have to exist in order for values to be stored in a class's static fields. Selected Answer:

Tru e

Question 10



5 out of 5 points

The names of the enum constants in an enumerated data type must be enclosed in quotation marks. Selected Answer:

Fals e

Question 11



5 out of 5 points

Whi choft hef ol l owi ngi snoti nvol vedi ni dent i f yi ngt hecl as sest obeusedwhendev el opi ng anobj ect or i ent edappl i cat i on?

Selected Answer:

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



5 out of 5 points

A constructor Selected Answer:

has the same name as the class. Question 13



5 out of 5 points

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. Selected Answer:

Tru e

Question 14



5 out of 5 points

Methods that operate on an object's fields are called Selected Answer:

instance methods. Question 15



5 out of 5 points

A constructor is a method that is automatically called when an object is created. Selected

Tru

Answer:

e

Question 16



5 out of 5 points

Which of the following is not involved in identifying the classes to be used when developing an object-oriented application? Selected Answer:

Write the code. Question 17



5 out of 5 points

The public access specifier for a field indicates that the field may not be accessed by statements outside the class. Selected Answer:

Fals e

Question 18



5 out of 5 points

The term "no-arg constructor" is applied to any constructor that does not accept arguments. Selected Answer:

Tru e

Question 19



5 out of 5 points

If you do not provide initialization values for a class's numeric fields, they will Selected Answer:

be automatically initialized to 0. Question 20



5 out of 5 points

For the following code, which statement is not true?

Selected Answer:

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

Examen



Question 1 2.5 out of 2.5 points

Assume the class BankAccount has been created and the following statement correctly creates an instance of the class.

BankAccount account = new BankAccount(5000.00);

What is true about the following statement? System.out.println(account); Selected Answer:

The account object's toString method will be implicitly called. Question 2



2.5 out of 2.5 points

If the following is from the method section of a UML diagram, which of the statements shown is true? + equals(object2:Stock) : boolean Selected Answer:

This is a public method that accepts a Stock object as its argument and returns a boolean value. Question 3



2.5 out of 2.5 points

What is the following statement an example of? import java.util.Scanner; Selected Answer:

an explicit import statemen t Question 4



2.5 out of 2.5 points

When a method's type is an object, what is actually returned by the calling program? Selected Answer:

a reference to an object of that class Question 5



0 out of 2.5 points

You can use the enum key word to Selected Answer:

create your own data type. Question 6



2.5 out of 2.5 points

"Shadowing" is the term used to describe how the field name is hidden by the name of a local or parameter variable. Selected Answer:

Tru e

Question 7



2.5 out of 2.5 points

Which is the key word used to import a class? Selected Answer:



import

Question 8 2.5 out of 2.5 points

Which symbol indicates that a member is public in a UML diagram? Selected Answer:

+

Question 9



2.5 out of 2.5 points

Assume the following declaration exists: enum Tree ( OAK, MAPLE, PINE )

What will the following code display? System.out.println(Tree.OAK); Selected Answer:

OAK

Question 10



2.5 out of 2.5 points

A method Selected Answer:

may have zero or more parameters. Question 11



2.5 out of 2.5 points

A declaration for an enumerated type begins with the ________ key word. Selected Answer:

enum

Question 12



2.5 out of 2.5 points

What does the following UML diagram entry mean? + setHeight(h : double) : void Selected Answer:

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



2.5 out of 2.5 points

You can declare an enumerated data type inside a method. Selected Answer:

Fals e

Question 14



2.5 out of 2.5 points

The term "default constructor" is applied to the first constructor written by the author of the class. Selected Answer:



Fals e

Question 15 2.5 out of 2.5 points

For the following code, which statement is not true?

Selected Answer:

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



2.5 out of 2.5 points

One or more objects may be created from a(n) Selected Answer:

clas s. Question 17



2.5 out of 2.5 points

If object1 and object2 are objects of the same class, to make object2 a copy of object1 Selected Answer:

write a method for the class that will make a field by field copy of object1 data members into object2 data members. Question 18



2.5 out of 2.5 points

Which of the following is not involved in identifying the classes to be used when developing an object-oriented application? Selected Answer:

Write the code. Question 19



2.5 out of 2.5 points

A method's signature consists of Selected Answer:

the method name and the parameter list. Question 20



2.5 out of 2.5 points

Overloading is Selected Answer:

having two or more methods with the same name but different signatures. Question 21



0 out of 2.5 points

A static field is created by placing the key word static Selected Answer:



after the access specifier and the field's data type. Question 22 2.5 out of 2.5 points

If you have defined a class, SavingsAccount, with a public static method, getNumberOfAccounts, and created a SavingsAccount object referenced by the variable account20, which of the following will call the getNumberOfAccounts method?

Selected Answer:

SavingsAccount.getNumberOfAccounts();

Question 23



2.5 out of 2.5 points

A class's static methods do not operate on the fields that belong to any instance of the class. Selected Answer:

Tru e

Question 24



2.5 out of 2.5 points

CRC stands for Selected Answer:

Class, Responsibilities, Collaborations. Question 25



2.5 out of 2.5 points

Which symbol indicates that a member is private a UML diagram? Selected Answer:

-

Question 26



2.5 out of 2.5 points

When an argument is passed by value Selected Answer:

the parameter variable holds the address of the argument. Question 27



2.5 out of 2.5 points

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. Selected Answer:

Tru e

Question 28



2.5 out of 2.5 points

After the header, the body of the method appears inside a set of Selected Answer:

braces, { }

Question 29



2.5 out of 2.5 points

The key word new Selected Answer:



creates an object in memory. Question 30 2.5 out of 2.5 points

When the this variable is used to call a constructor

Selected Answer:

it must be the first statement in the constructor making the call. Question 31



2.5 out of 2.5 points

When you make a copy of the aggregate object and of the objects that it references, Selected Answer:

you are performing a deep copy. Question 32



2.5 out of 2.5 points

Methods that operate on an object's fields are called Selected Answer:

instance methods. Question 33



2.5 out of 2.5 points

Data hiding (which means that critical data stored inside the object is protected from code outside the object) is accomplished in Java by Selected Answer:

using the private access specifier on the class fields. Question 34



2.5 out of 2.5 points

An enumerated data type is actually a special type of class. Selected Answer:

Tru e

Question 35



2.5 out of 2.5 points

Which of the following can you use to compare two enum data values? Selected Answer:

the equals and compareTo met hods Question 36



2.5 out of 2.5 points

The only limitation that static methods have is Selected Answer:

they cannot refer to nonstatic members of the class. Question 37



2.5 out of 2.5 points

The scope of a local variable is Selected Answer:



the method in which it is defined. Question 38 2.5 out of 2.5 points

Enumerated types have the ________ method which returns the position of an enum constant in the declaration list. Selected Answer:

ordinal

Question 39



0 out of 2.5 points

A group of related classes is called a(n) archiv e.

Selected Answer: Debe ser

package

Question 40



2.5 out of 2.5 points

A class's responsibilities include Selected Answer:

both of these.

2 examen

Question 1 2.5 out of 2.5 points The "has a" relationship is sometimes called a(n) ________ because one object is part of a greater whole. Selected Answer: whole-part relationship

Question 2 2.5 out of 2.5 points The key word new Selected Answer:

creates an object in memory.

Question 3 2.5 out of 2.5 points The scope of a local variable is Selected Answer: the method in which it is defined.

Question 4 2.5 out of 2.5 points When a method's type is an object, what is actually returned by the calling program? Selected Answer: a reference to an object of that class

Question 5 2.5 out of 2.5 points If object1 and object2 are objects of the same class, to make object2 a copy of object1 Selected Answer: write a method for the class that will make a field by field copy of object1 data members into object2 data members.

Question 6 2.5 out of 2.5 points If a class has a method named finalize, it is called automatically just before an instance of the class is destroyed by the garbage collector. Selected Answer: True

Question 7 2.5 out of 2.5 points A group of related classes is called a(n) Selected Answer:

package.

Question 8 2.5 out of 2.5 points Assume the following declaration exists: enum Tree ( OAK, MAPLE, PINE ) What will the following code display? System.out.println(Tree.OAK); OAK Selected Answer:

Question 9 2.5 out of 2.5 points You can use the enum key word to Selected Answer:

F Both of these

Question 10 2.5 out of 2.5 points For the following code, which statement is not true?

Selected Answer:

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

Question 11 2.5 out of 2.5 points UML diagrams do not contain Selected Answer: object names.

Question 12 2.5 out of 2.5 points If you write a toString method for a class, Java will

automatically call the method any time you concatenate an object of the class with a string. Selected Answer: True

Question 13 2.5 out of 2.5 points You cannot use the fully-qualified name of an enum constant for Selected Answer: a case expression.

Question 14 2.5 out of 2.5 points If the following is from the method section of a UML diagram, which of the statements shown is true? + equals(object2:Stock) : boolean Selected Answer: This is a public method that accepts a Stock object as its argument and returns a boolean value.

Question 15 2.5 out of 2.5 points After the header, the body of the method appears inside a set of Selected Answer: braces, { }

Question 16 2.5 out of 2.5 points When you write an enumerated type declaration, you Selected Answer: All of these

Question 17 2.5 out of 2.5 points The public access specifier for a field indicates that the field may not be accessed by statements outside the class. Selected Answer: False

Question 18 2.5 out of 2.5 points An access specifier indicates how a class may be accessed. Selected Answer: True

Question 19 2.5 out of 2.5 points One or more objects may be created from a(n) Selected Answer: class.

Question 20 2.5 out of 2.5 points Given the following method header, what will be returned from the method? public Rectangle getRectangle() Selected Answer: the address of an object of the Rectangle class

Question 21 2.5 out of 2.5 points A class that is defined inside another class is called a(n) Selected Answer:

inner class.

Question 22 2.5 out of 2.5 points Of the following, which would be considered the no-arg constructor for the Rectangle class? public Selected Answer:

Rectangle()

Question 23 2.5 out of 2.5 points If you do not provide initialization values for a class's numeric fields, they will

Selected Answer:

be automatically initialized to 0.

Question 24 2.5 out of 2.5 points You should not define a class that is dependent on the values of other class fields Selected Answer: in order to avoid having stale data.

Question 25 2.5 out of 2.5 points

enum constants have a toString method. Selected Answer:

True

Question 26 2.5 out of 2.5 points What is the following statement an example of? import java.util.*; Selected Answer: a wildcard import statement

Question 27 2.5 out of 2.5 points A constructor is a method that is automatically called when an object is created. Selected Answer: True

Question 28 2.5 out of 2.5 points 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. Selected Answer: objects

Question 29 2.5 out of 2.5 points

If you have defined a class, SavingsAccount, with a public static method, getNumberOfAccounts, and created a SavingsAccount object referenced by the variable account20, which of the following will call the getNumberOfAccounts method? SavingsAccount. Selected Answer:

getNumberOfAcco unts();

Question 30 2.5 out of 2.5 points A class's static methods do not operate on the fields that belong to any instance of the class. Selected Answer: True

Question 31 2.5 out of 2.5 points Which of the following is not involved in identifying the classes to be used when developing an object-oriented application? Selected Answer: Write the code.

Question 32 2.5 out of 2.5 points When a local variable in an instance method has the same name as an instance field, the instance field hides the local variable. Selected Answer: False

Question 33 2.5 out of 2.5 points Enumerated types have the ________ method which returns the position of an enum constant in the declaration list. ordinal Selected Answer:

Question 34 2.5 out of 2.5 points

A static field is created by placing the key word

static Selected Answer:

after the access specifier and before the field's data type.

Question 35 2.5 out of 2.5 points Class objects normally have ________ that perform useful operations on their data, but primitive variables do not. Selected Answer: methods

Question 36 2.5 out of 2.5 points For the following code, which statement is not true?

Selected Answer:

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

Question 37 2.5 out of 2.5 points A declaration for an enumerated type begins with the ________ key word. enum Selected Answer:

Question 38 2.5 out of 2.5 points The key word this is the name of a reference variable that an object can use to refer to itself. Selected Answer: True

Question 39 2.5 out of 2.5 points When a field is declared static there will be Selected Answer:

only one copy of the

field in memory.

Question 40 2.5 out of 2.5 points You can declare an enumerated data type inside a method. Selected Answer: False...


Similar Free PDFs