READ Free Dumps For Oracle- 1z0-804
Question ID 21417 | Given these facts about Java types in an application:
- Type x is a template for other types in the application.
- Type x implements dostuff ().
- Type x declares, but does NOT implement doit().
- Type y declares doOther() .
Which three are true?
|
Option A | Type y must be an interface.
|
Option B | Type x must be an abstract class.
|
Option C | Type y must be an abstract class.
|
Option D | Type x could implement or extend from Type y.
|
Option E | Type x could be an abstract class or an interface.
|
Option F | Type y could be an abstract class or an interface.
|
Correct Answer | B,D,F |
Explanation Explanation: Unlike interfaces, abstract classes can contain fields that are not static and final, and they can contain implemented methods. Such abstract classes are similar to interfaces, except that they provide a partial implementation, leaving it to subclasses to complete the implementation. If an abstract class contains only abstract method declarations, it should be declared as an interface instead. Note: An interface in the Java programming language is an abstract type that is used to specify an interface (in the generic sense of the term) that classes must implement. Interfaces are declared using the interface keyword, and may only contain method signature and constant declarations (variable declarations that are declared to be both static and final). An interface may never contain method definitions. Note 2: an abstract class is a class that is declared abstract--it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed. An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon)
Question ID 21418 | Given:
public abstract class Account {
abstract void deposit (double amt);
public abstract Boolean withdraw (double amt);
}
public class CheckingAccount extends Account {
}
What two changes, made independently, will enable the code to compile?
|
Option A | Change the signature of Account to: public class Account.
|
Option B | Change the signature of CheckingAccount to: public abstract CheckingAccount
|
Option C | Implement private methods for deposit and withdraw in CheckingAccount.
|
Option D | Implement public methods for deposit and withdraw in CheckingAccount.
|
Option E | Change Signature of checkingAccount to: CheckingAccount implements Account.
|
Option F | Make Account an interface.
|
Correct Answer | B,D |
Explanation Explanation: Compiler say: - Der Typ CheckingAccount muss die übernommene abstrakte Methode Account.deposit(double) implementieren - Der Typ CheckingAccount muss die übernommene abstrakte Methode Account.withdraw(double) implementieren ODER Typ CheckingAccount als abstract definieren