Ch 9: Text Processing and More about Wrapper Classes & Ch 10: Inheritance

¡Supera tus tareas y exámenes ahora con Quizwiz!

In a class hierarchy:

The more general classes are toward the top of the tree and the more specialized are toward the bottom

If a superclass does not have a default constructor:

Then a class that inherits from it, must call one of the constructors that the superclass does have

T or F: If a method in a subclass has the same signature as a method in the superclass, the subclass method overloads the superclass method.

False

T or F: If two methods in the same class have the same name but different signatures, the second overrides the first.

False

T or F: In an inheritance relationship, the derived class constructor always executes before the superclass constructor.

False

T or F: You cannot assign a value to a wrapper class object.

False

Look at the following code. Which line in ClassA has an error? public interface MyInterface { int FIELDA = 55; public int methodA(double); } public class ClassA implements MyInterface { FIELDA = 60; public int methodA(double) { } }

Line 8 FIELDA = 60;

T or F: It is not possible for a superclass to call a subclass's method.

True

Assuming that str is declared as follows, String str = "RSTUVWXYZ"; what value will be returned from str.charAt(5)?

W

What will be printed after the following code is executed? String str = "abc456"; int m = 0; while ( m < 6 ) { if (!Character.isLetter(str.charAt(m))) { System.out.print(Character.toUpperCase(str.charAt(m))); m++; } }

456

Which of the following is true about protected access? A. Protected members may be accessed by methods in the same package or in a subclass, even when the subclass is in a different package B. Protected members may be accessed by methods in the same package or in a subclass, but only if the subclass is in the same package C. Protected members cannot be accessed by methods in any other classes D. Protected members are actually named constants

A. Protected members may be accessed by methods in the same package or in a subclass, even when the subclass is in a different package

To convert the string, str = "285.74" to a double and store it in the variable x, use the following statement: A. double x = str; B. double x = Double.parseDouble(str); C. double x = Double.Double(str); D. double x = str,Double.parseDouble;

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

If you do not specify delimiters in the StringToken constructor, which of the following cannot be a delimiter? A. Space B. Tab C. Semicolon D. Newline

C. Semicolon

In the following statement, which is the interface? public class ClassA extends ClassB implements ClassC

ClassC

If a class contains an abstract method: A. You cannot create an instance of the class B. The method will have only a header, but not a body, and end with a semicolon C. The method must be overridden in subclasses D. All of these

D. All of these

Using the StringBuilder class's insert method, you can insert: A. A primitive type B. A String object C. A char array D. All of these

D. All of these

What does the following statement do? Float number = new Float(8.8); A. It creates a Float object B. It initializes that object to 8.8 C. It assigns the object's address to the number variable D. All of these

D. All of these

Use the following import statement when using the Character wrapper class:

No import statement is needed

In an interface all methods have:

Public access

If ClassA is derived from ClassB, then:

Public members in ClassB are public in ClassA, but private members in ClassB cannot be directly accessed in ClassA

In the following statement, what data type must recField be? str.getChars(5, 10, recField, 0);

char [ ]

If str is declared as String str = "ABCDEFGHI"; what will be returned from Character.toLowerCase(str.charAt(5))?

f

What would be the results of executing the following code? StringBuilder str = new StringBuilder("Little Jack Horner "); str.append("sat on the "); str.append("corner");

str would equal "Little Jack Horner sat on the corner"

What would be the results of executing the following code? StringBuilder str = new StringBuilder(12); str.append("The cow"); str.append(" jumped over the "); str.append("moon.");

str would equal "The cow jumped over the moon."


Conjuntos de estudio relacionados

Personal Uses of Life Insurance (CH 3)

View Set

Chapter 6 through 9 Post and Pre Test

View Set

MGMT 4860 Chapter 4 Cost Advantage

View Set

Chapter 13 - Prioritization, Delegation, and Assignment

View Set

Chapter 19 Reduced Voltage Starting

View Set

CISSP-8-Software-Development-Security

View Set