QuizMe
Open main menu
Login
Create a quiz
Java
1: Polymorphism enables you to:
program in the general.
program in the specific.
absorb attributes and behavior from previous classes.
hide information from the user.
2: For which of the following would polymorphism NOT provide a clean solution?
A billing program where there is a variety of client types that are billed with different fee structures.
A maintenance log program where data for a variety of types of machines is collected and maintenance schedules are produced for each machine based on the data collected.
A program to compute a 5% savings account interest for a variety of clients.
An IRS program that maintains info on a variety of taxpayers and determines who to audit based on criteria for classes of taxpayers.
3: Polymorphism allows for specifics to be dealt with during:
execution.
compilation.
programming.
debugging.
4: A(n) _______ class cannot be instantiated.
abstract
final
concrete
polymorphic
5: Which statement best describes the relationship between superclass and subclass types?
A subclass reference cannot be assigned to a superclass variable and a superclass reference cannot be assigned to a subclass variable.
A subclass reference can be assigned to a superclass vaiable and a superclass reference can be assigned to a subclass variable.
A superclass reference can be assigned to a subclass variable, but a subclass reference cannot be assigned to a superclass variable.
A subclass reference can be assigned to a superclass variable, but a supercclass reference cannot be assigned to a subclass variable.
6: It is a UML convention to denote the name of an abstract class in:
bold.
italics.
a diamond.
there is no convention of the UML to denote abstract classes - they are listed just as any other class.
7: Non-abstract classes are called:
real classes.
instance classes.
imlementable classes.
concrete classes.
8: Which of the following could be used to declare abstract method method1 in abstract class Class1?
public int method1();
public int abstract method1();
public abstract int method1();
public int nonfinal method1();
9: If the superclass contains only abstract method declarations, the superclass is used for:
implementation inheritance.
interface inheritance.
both.
neither.
10: Which of the following statements about abstract superclassesis true?
abstract superclasses may contain data.
abstract superclasses may NOT contain implementations of methods.
abstract superclasses must declare all methods as abstract.
abstract superclasses must declare all data members not given values as abstract.
11: An anonymous String:
has no value.
is a string literal.
can be changed.
None of the above.
12: A String constructor CANNOT be passed:
char arrays.
int arrays.
byte arrays.
Strings.
13: The length of a string can be determined by:
the String method length().
the String instance variable length.
the String method strlen().
All of the above.
14: String objects are immutable. This means they:
must be initialized.
cannot be deleted.
cannot be changed.
None of the above.
15: The String method substring returns:
a char.
a String.
Void.
a char[].
16: Which of the following is NOT a method of class String?
to UpperCase
trim
toCharacterArray
All of the above are methods of class String.
17: Which of the following statements is true?
The capacity of a StringBuilder is equal to its length.
The capacity of a StringBuilder cannot exceed its length.
The length of a StringBuilder cannot exceed its capacity.
None of the above are true.
18: To find the character at a certain index position within a String, use the method:
getChars, with the index as an argument.
getCharAt, with the index as an argument.
charAt, with the index as an argument..
charAt, with the character you are searching for as an argument.
19: Which of the following are NOT static Character methods?
Character.hashcode(char c);
Character.isDigit(char c);
Character.equals(char c);
All of the above.
20: Which class is NOT a type-wrapper class?
Character.
Int
Double
Byte
21: Inheritance is also known as the:
knows-a relationship.
has-a relationship.
uses-a relationship.
is-a relationship.
22: An advantage of inheritance is that.
All methods can be inherited.
All instance variables can be uniformly accessed by subclasses and superclasses.
Objects of a subclass can be treated like objects of their superclass.
None of the above.
23: Which of the following keywords allows a subclass to access a superclass method even when the subclass has overridden the superclass method?
base.
this.
public.
super.
24: Using the protected keyword also gives a member:
public access.
package access.
private access.
block scope.
25: Every class in Java, except ______, extends an existing class.
Integer
Object
String
Class
26: Every class in Java, except ______, extends an existing class.
Integer
Object
String
Class
27: Every class in Java, except ______, extends an existing class.
Integer
Object
String
Class
28: Overriding a method differs from overloading a method because:
Overloaded methods have the same signature.
Overridden methods have the same signature.
Both of the above.
Neither of the above.
29: Which of the following is the superclass constructor call syntax?
keyword super, followed by a dot(.),
keyword super, followed by a set of parentheses containing the superclass constructor arguments.
keyword super, followed by a dot and the superclass constructor name.
None of the above.
30: Which statement is true when a superclass has protected instance variables?
A subclass object can assign an invalid value to the superclass's instance variables, thus leaving an object in an inconsistent state.
Subclass methods are more likely to be written so that they depend on the superclass's data implementation.
We may need to modify all the subclasses of the superclass if the superclass implementation changes.
All of the above.
31: Private fields of a superclass can be accessed in a subclass
by calling private methods declared in the superclass.
by calling public or protected methods declared in the superclass.
directly.
All of the above.
32: Which superclass members are inherited by all subclasses of that superclass?
private instance variables and methods.
protected instance vaiables and methods.
private constructors.
protected constructors.
33: Which of the following statements is false?
Exception handling enables programmers to write robust and fault-tolerant programs.
Exception handling can catch but not resolve exceptions.
Exception handling can resolve exceptions.
All of the above are true.
34: When an exception occurs it is said to have been:
caught.
thrown.
declared.
handled.
35: Which of the following is not included in an exception's stack trace?
A descriptive message for the exception.
The method-call stack at the timethe exception occurred.
The name of the exception.
Instructions on handling the exception.
36: Which of the following statements regarding the throw point of an exception is FALSE?
It specifies the point at which the exception must be handled.
It is the initial point at which the exception occurs.
It is specified as the top row of the method-call stack at the time the exception occurred.
All of the above statements are true.
37: To catch an exception, the code that might throw the exception must be enclosed in a:
throws block.
catch block.
try block.
finally block.
38: Exceptions can be thrown by:
the Java Virtual Machine.
code in a try block.
call from a try block to other methods.
All of the above.
39: An uncaught exception:
is a possible exception that never actually occurs during the execution of the program.
is an exception that occurs for which the matching catch clause is empty.
is an exception that occurs for which there are no matching catch clauses.
is another term for a thrown exception.
40: Which of the following statements about try blocks is true?
The try block must be followed by at least one catch block.
The try block must be followed by a finally block.
The try block should contain statements that may process an exception.
The try block should contain statemtns that may throw an exception.
41: In Java, after an excpetion is handled, control resumes ____. This is known as the _____ model of exception handling.
after the last catch block(or the finally block, if there is one), termination
after the last catch block(or the finally block, if there is one), resumption
just after the throw point, termination
just after the throw point, resumption
42: All exception classes inherit, either directly or indirectly, from:
class Error.
class RuntimeException.
class Throwable.
None of the above.