Programming Chapters 8,9, and 10

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

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

a case expression

_______ is the term for the relationship created by object aggregation.

"Has a"

The whole-part relationship created by object aggregation is more often called a(n) _______ relationship.

"has a"

When a field is declared static there will be ________.

only one copy of the field in memory

If two methods have the same name but different signatures they are ______.

overloaded

All methods specified by an interface are _______.

public

When a reference variable is passed as an argument to a method _______.

the method has access to the object that the variable references

Given the following declaration: enum Tree( OAK, MAPLE, PINE ) What is the ordinal value of MAPLE enum constant?

1

Which of the following statements will display the maximum value that a double can hold? A. System.out.println(Double.MAX__VALUE); B. System.out.println(Double.MAXIMUM__VALUE); C. System.out.println(<double(MAX__VALUE)); D. System.out.println(Double.MAX__VAL);

A. System.out.println(Double.MAX__VALUE);

When a method is declared with the _______ modifier, it cannot be overridden in a subclass.

final

A class that is defined inside another class is called a(n) ________.

inner class

The _______ term is commonly used to refer to a string that is part of another string

substring

The String class's regionMatches method performs a case-insensitive comparison. (true/false).

true

When working with the String and StringBuilder classes' getChars method, the character at the start position is included in the substring but the character at the end position is not included. (true/false)

true

if you are using characters other than whitespaces as delimiters, you will probably want to trim the string before tokenizing ; otherwise, the leading and/or following whitespaces will become part of the first and/or last token. (true/false)

true

The "has a" relationship sometimes called a(n) _______ because one object is part of a greater whole.

whole-part relationship

When you make a copy of the aggregate object and of the objects that it references, _______.

you are performing a deep copy

Which of the following statements will convert the string, str = "285.74" to double? A. double x = Double.parseDouble(str); B. double x = Double.Double(str); C. double x = str.Double.parseDouble; D. double x = str;

A. double x = Double.parseDouble(str);

A subclass can directly access _____. A. only public and protected members of the superclass B. all members of the superclass C. only public and private members of the superclass D. only protected and private members of the superclass

A. only public and protected members of the superclass

if you write a toString method to display the contents of an object, object1, for a class, Class1, then the following two statements are equivalent: System.out.println(object1); System.out.println(objects1.toString()); (true/false)

true

_______ tells the java compiler that a method is meant to override a method in the superclass.

@Override

________ is a special type of expression used to create an object that implements a functional interface. A. Lambda B. Sigma C. Alpha D. Beta

A. Lambda

If the following is from the method section of a UML diagram, which of the statements below is true? + add(object2:Stock) : Stock A. This is a private method name Stock that adds two objects B. This is a public method named add that accepts and returns references to objects in the Stock class. C. This is a public method named Stock that adds two objects.

B. This is a public method named add that accepts and returns references to objects in the Stock class.

in ________, inheritance is shown with a line that has an open arrowhead at one end that points of the superclass. A. pseudocode B. a UML diagram C. a CRC card D. a hierarchy chart

B. a UML diagram

Which of the following is an example of a lambda expression? A. int x = x * factor; B. IntCalculator = new divider(x, 2); C. IntCalculator multiplier = x -> x * factor; D. Any of these are examples of a lambda expression.

C. IntCalculator multiplier = x -> x * factor;

Which of the following shows the inheritance relationships among classes in a manner similar to that of a family tree? A. UML diagram B. CRC card C. class hierarchy D. flowchart

C. class hierarchy

What would be the results of executing the following code? StringBuilder str = new StringBuilder("Little Jack Horner "); str.append("sat on the "); strappend("corner"); A. str would reference "Little Jac Horner sat on the". B. str would reference "Little Jack Horner". C. The program would crash. D. str would reference "Little Jack Horner sat on the corner".

D. str would reference "Little Jack Horner sat on the corner".

What will be the value of matches after the following code is executed? boolean matches; String[] productCodes = {"456HI345", "3456hj"}; matches = productCodes[0].regionMatches(true, 1, productCodes[1], 2, 3); A. false B. 56h C. 56H D. true

D. true

If object 1 and object2 are objects of the same class, to make object2 a copy of object1 _______. A. use an assignment statement to make object2 a copy of object1 B. use the copy method that is a part of the java language C. use the default constructor to create object2 with object1 data members D. write a method for the class that will make a field by field copy of object1 data members into ojbect2 data members

D. write a method for the class that will make a field by field copy of object1 data members into ojbect2 data members

Each of the numeric wrapper classes has a static ________ method that converts a number to a string.

ToString

Because the subclass is more specialized than the superclass, it is sometimes necessary for the subclass to replace inadequate superclass methods with more suitable ones. (true/false)

True

All fields declared in an interface _______.

are treated as final and static

if a class has a method named finalize, it is called automatically just before a data member that has been identified as final of the class is destroyed by the garbage collector. (true/false)

false

A single copy of a class's field is shared by all instances of the class. (true/false)

true

Every class has a toString method and an equals method inherited from the Object class. (true/false)

true

Which of the following is not true about static methods? A. They are often used to create utility classes that perform operations on data but have no need to store and collect data B. They are called directly from the class. C. It is necessary for an instance of the class to be created to execute the method. D. They are created by placing the key word static after the access specifier in the method header.

C. It is necessary for an instance of the class to be created to execute the method.

Autoboxing is _______. A. the process of assigning a default value to primitive data types B. the process of identifying tokens in a string C. Java's process of automatically "boxing up" a value inside an object D. The automatic allocation of array elements

C. Java's process of automatically "boxing up" a value inside an object

Assume the class BankAccount has been created, and the following statement correctly creates an instance of the class: BankAccount account = new BankAccount(5000.0); What is true about the following statement? System.out.println(account); A. A compiler error will occur. B. The method will display unreadable binary data on the screen. C. The account object's toString method will be implicitly called. D. A runtime error will occur.

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

To compare two objects in a class, _______. A. use the == operator (for example, object1 == object2) B. write a method to do a byte-by-byte compare of the two objects C. write an equals method that will make a field by field compare of the two objects D. This cannot be done since objects consists of several fields.

C. write an equals method that will make a field by field compare of the two objects

In the following statements, which is the superclass? public class ClassA extends ClasB implents ClassC

ClassB

Which of the following import statements is required to use the Character wrapper class? A. import java.String; B. import java.lang.Char; C. import java.Char; D. No import statement is required

D. No import statement is required

What is the value of str after the following code has been executed? String str; String sourceStr = "Hey diddle, diddle, the cat and the fiddle"; str = source Str.substring(12,17); A. iddle B. iddle C. did D. diddl

D. diddl

if the following is from the method section of a UML diagram, which of the statements below is true? + equals(object2:Stock) : boolean A. This is a private method that returns a boolean value. B. This is a public method that returns a reference to a String object. C. This is a private method that receives two objects from the Stock class and returns a boolean value. D. This is a public method that accepts a Stock object as its argument and returns a boolean value.

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


Kaugnay na mga set ng pag-aaral

Which of the following statements about distance and/or displacement are TRUE? List all that apply.

View Set

PN Human Growth and Development Assessment

View Set

FTCE Social Science Review Material !!!!!!!

View Set

Life Insurance Policy Provisions, Options & Riders

View Set

What is the capital/biggest city... Southwest Asia, North Africa

View Set

Nervous System Part B and Special Senses exam

View Set

Chapter 39- The Balance of Payments, Exchange Rates, and Trade Deficits

View Set