Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
38 Cards in this Set
- Front
- Back
Which are true? (Choose all that apply.) A. "X extends Y" is correct if and only if X is a class and Y is an interface. B. "X extends Y" is correct if and only if X is an interface and Y is a class. C. "X extends Y" is correct if X and Y are either both classes or both interfaces. D. "X extends Y" is correct for all combinations of X and Y being classes and/or interfaces. |
C is correct A is incorrect because classes implement interfaces, they don't extend them. B is incorrectbecause interfaces only "inherit from" other interfaces. D is incorrect based on the precedingrules. |
|
"static imports," the syntax is import static… |
true Ex: import static org.hamcrest.Matchers.hasProperty; |
|
A source code file can have more than one public class. |
false A source code file can have only one public class. |
|
Files with no public classes have no naming restrictions. |
True Files with no public classes have no naming restrictions. |
|
Classes can also be modified only with final, abstract |
False Classes can also be modified only with final, abstract, or strictfp |
|
A single abstract method in a class doesn't mean the whole class must beabstract. |
False A single abstract method in a class means the whole class must beabstract. |
|
The first concrete class to extend an abstract class must implement all of itsabstract methods |
True The first concrete class to extend an abstract class must implement all of itsabstract methods |
|
Interfaces are contracts for what a class can do, but they say nothing aboutthe way in which the class must do it |
True Interfaces are contracts for what a class can do, but they say nothing aboutthe way in which the class must do it |
|
Interface constant declarations of public, static, and final are optionalin any combination |
True Interface constant declarations of public, static, and final are optionalin any combination |
|
A legal nonabstract implementing class has the following properties: It could declare any new checked exceptions for an implementationmethod. |
False It must not declare any new checked exceptions for an implementationmethod. |
|
A legal nonabstract implementing class has the following properties: It must not declare any checked exceptions that are broader than theexceptions declared in the interface method. |
True It must not declare any checked exceptions that are broader than theexceptions declared in the interface method. |
|
A legal nonabstract implementing class has the following properties: It may declare runtime exceptions on any interface methodimplementation regardless of the interface declaration. |
True It may declare runtime exceptions on any interface methodimplementation regardless of the interface declaration. |
|
A legal nonabstract implementing class has the following properties: It must maintain the exact signature (allowing for covariant returns) andreturn type of the methods it implements (but does not have to declarethe exceptions of the interface). |
True |
|
If a class cannot be accessed, its members can be accessed. |
False If a class cannot be accessed, its members cannot be accessed. |
|
protected members can be accessed only by subclasses regardless of package |
False protected members can be accessed by other classes in the samepackage, plus subclasses regardless of package |
|
protected = package + kids (kids meaning subclasses) |
True protected = package + kids (kids meaning subclasses) |
|
A protected member inherited by a subclass from another package isnot accessible to any other class in the subclass package, except for thesubclass' own subclasses. |
True A protected member inherited by a subclass from another package isnot accessible to any other class in the subclass package, except for thesubclass' own subclasses. |
|
Local variables have default values |
False Local variables don't get default values, so they must be initialized before use |
|
abstract methods end in a semicolon—no curly braces. |
True abstract methods end in a semicolon—no curly braces. |
|
The synchronized modifier applies only to methods and code blocks. |
True The synchronized modifier applies only to methods and code blocks. |
|
The strictfp modifier applies only to classes. |
False The strictfp modifier applies only to classes and methods. |
|
abstract methods cannot be protected. |
False abstract methods must be implemented by a subclass, so they must beinheritable. For that reason: ❑ abstract methods cannot be private. ❑ abstract methods cannot be final |
|
In methods with normal parameters and a var-arg, the var-arg must come last |
True In methods with normal parameters and a var-arg, the var-arg must come last |
|
A var-arg method can have multiple var-arg parameters. |
False A var-arg method can have only one var-arg parameter. |
|
Instance variables can ❑ Have any access control ❑ Be marked final or transient |
True Instance variables can ❑ Have any access control ❑ Be marked final |
|
Instance variables can be abstract, synchronized, native, or strictfp. |
False Instance variables can't be abstract, synchronized, native, or strictfp. |
|
final variables can be reassigned once assigned a value. |
False final variables cannot be reassigned once assigned a value. |
|
final variables must be initialized before the constructor completes |
True final variables must be initialized before the constructor completes |
|
An object reference markedfinal does NOT mean the object itself can't change |
True An object reference markedfinal does NOT mean the object itself can't change |
|
The transient modifier applies only to instance variables. |
True The transient modifier applies only to instance variables. |
|
The volatile modifier applies only to instance variables. |
True The volatile modifier applies only to instance variables. |
|
When you declare an array, the brackets can be to the left or to the right ofthe variable name |
True When you declare an array, the brackets can be to the left or to the right ofthe variable name |
|
An array of objects can hold any object that passes the IS-A (orinstanceof) test for the declared type of the array. For example, if Horseextends Animal, then a Horse object can go into an Animal array. |
True An array of objects can hold any object that passes the IS-A (orinstanceof) test for the declared type of the array. For example, if Horseextends Animal, then a Horse object can go into an Animal array. |
|
An enum can be declared outside or inside a class and in a method |
False An enum can be declared outside or inside a class, but NOT in a method |
|
An enum declared outside a class must could be marked static, final,abstract, protected, or private |
False An enum declared outside a class must NOT be marked static, final,abstract, protected, or private |
|
enum constructors can NEVER be invoked directly in code. They are alwayscalled automatically when an enum is initialized. |
True enum constructors can NEVER be invoked directly in code. They are alwayscalled automatically when an enum is initialized. |
|
The semicolon at the end of an enum declaration is mandatory |
False The semicolon at the end of an enum declaration is optional |
|
MyEnum.values() returns an array of MyEnum's values |
True MyEnum.values() returns an array of MyEnum's values |