CSCI-C201 Midterm Review
Autoboxing is __________.
Java's process of automatically "boxing up" a value inside an object
A(n) __________ method is a method that appears in a superclass but expects to be overridden in a subclass.
abstract
When an "is a" relationship exists between objects, the specialized object has __________.
all of the characteristics of the general object plus additional characteristics
When the this variable is used to call a constructor__________.
it must be the first statement in the constructor making the call
In the following code, which line has an error? public interface Interface1 { int FIELDA = 55; public int methodA(double){} }
line 4
In Java, a reference variable is __________ because it can reference objects of types different from its own, as long as those types are related to its type through inheritance.
polymorphic
The __________ method of the String class can be used to tokenize a string.
split
The __________ key word is used to call a superclass constructor explicitly.
super
When a reference variable is passed as an argument to a method __________.
the method has access to the object that the variable references
If a class contains an abstract method __________.
the method will only have a header, but not a body, and will end with a semicolon
In an inheritance relationship __________.
the superclass constructor always executes before the subclass constructor
The only limitation that static methods have is __________.
they cannot refer to nonstatic members of the class
__________ is the term for the relationship created by object aggregation.
"Has a"
__________ tells the Java compiler that a method is meant to override a method in the superclass.
@Override
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++; }
ABC
The StringBuilder class's insert method allows you to insert a(n) __________ into the calling object's string. String object All of these char array primitive type
All of these
In Java it is possible to write a method that will return __________. a string of characters Any of these a reference to an object a whole number
Any of these
The __________ class is the wrapper class for the char data type.
Character
Which of the following is true about protected access?
Protected members may be accessed by methods in the same package or in a subclass, even when the subclass is in a different package.
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);
The account object's toString method will be implicitly called.
Which of the following is not true about static methods? They are called from an instance of the class. They are often used to create utility classes that perform operations on data but have no need to collect and store data. They are called by placing the key word static after the access specifier in the method header. It is not necessary for an instance of the class to be created to execute a static method.
They are called from an instance of the class.
If the following is from the method section of a UML diagram, which of the statements below is true? + equals(object2:Stock) : boolean
This is a public method that accepts a Stock object as its argument and returns a boolean value.
The JVM periodically performs the __________ process to remove unreferenced objects from memory.
garbage collection
Which of the following statements converts a String object variable named str to an int and stores the value in the variable x?
int x = Integer.parseInt(str);
A deep copy of an object __________.
is an operation that copies an aggregate object and all the objects that it referencesclass
The process of converting a wrapper class object to a primitive type is known as __________.
unboxing
What is the term used for a class that is "wrapped around" a primitive data type and allows you to create objects instead of variables?
wrapper class