Oracle 1z0-804 Exam Practice Questions (P. 2)
- Full Access (150 questions)
- Six months of Premium Access
- Access to one million comments
- Seamless ChatGPT Integration
- Ability to download PDF files
- Anki Flashcard files for revision
- No Captcha & No AdSense
- Advanced Exam Configuration
Question #6
Given:

What two changes, made independently, will enable the code to compile?

What two changes, made independently, will enable the code to compile?
- AChange the signature of Account to: public class Account.
- BChange the signature of CheckingAccount to: public abstract CheckingAccount
- CImplement private methods for deposit and withdraw in CheckingAccount.
- DImplement public methods for deposit and withdraw in CheckingAccount.
- EChange Signature of checkingAccount to: CheckingAccount implements Account.
- FMake Account an interface.
Correct Answer:
BD
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
BD
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
send
light_mode
delete
Question #7
Given:

Which fragment, inserted in the Books interface, enables the code to compile?

Which fragment, inserted in the Books interface, enables the code to compile?
- Apublic abstract String type; public abstract String getType();
- Bpublic static String type; public abstract String getType();
- Cpublic String type = "Fiction"; public static String getType();
- Dpublic String type = "Fiction"; public abstract String getType();
Correct Answer:
D
D
send
light_mode
delete
Question #8
Given:

What is the result?

What is the result?
send
light_mode
delete
Question #9
Which two forms of abstraction can a programmer use in Java?
- Aenums
- Binterfaces
- Cprimitives
- Dabstract classes
- Econcrete classes
- Fprimitive wrappers
Correct Answer:
BD
When To Use Interfaces -
An interface allows somebody to start from scratch to implement your interface or implement your interface in some other code whose original or primary purpose was quite different from your interface. To them, your interface is only incidental, something that have to add on to the their code to be able to use your package.
The disadvantage is every method in the interface must be public. You might not want to expose everything.
*When To Use Abstract classes
An abstract class, in contrast, provides more structure. It usually defines some default implementations and provides some tools useful for a full implementation.
The catch is, code using it must use your class as the base. That may be highly inconvenient if the other programmers wanting to use your package have already developed their own class hierarchy independently. In Java, a class can inherit from only one base class. *When to Use Both
You can offer the best of both worlds, an interface and an abstract class. Implementors can ignore your abstract class if they choose. The only drawback of doing that is calling methods via their interface name is slightly slower than calling them via their abstract class name.
Reference: http://mindprod.com/jgloss/interfacevsabstract.html
BD
When To Use Interfaces -
An interface allows somebody to start from scratch to implement your interface or implement your interface in some other code whose original or primary purpose was quite different from your interface. To them, your interface is only incidental, something that have to add on to the their code to be able to use your package.
The disadvantage is every method in the interface must be public. You might not want to expose everything.
*When To Use Abstract classes
An abstract class, in contrast, provides more structure. It usually defines some default implementations and provides some tools useful for a full implementation.
The catch is, code using it must use your class as the base. That may be highly inconvenient if the other programmers wanting to use your package have already developed their own class hierarchy independently. In Java, a class can inherit from only one base class. *When to Use Both
You can offer the best of both worlds, an interface and an abstract class. Implementors can ignore your abstract class if they choose. The only drawback of doing that is calling methods via their interface name is slightly slower than calling them via their abstract class name.
Reference: http://mindprod.com/jgloss/interfacevsabstract.html
send
light_mode
delete
Question #10
Given:

What is the result?

What is the result?
- AUp Down
- BUp Up
- CUp null
- DCompilation fails
- EAn exception is thrown at runtime
Correct Answer:
D
------
Exception in thread "main" java.lang.ExceptionInInitializerError at garden.Garden.main
Caused by: java.lang.RuntimeException: Uncompilable source code - garden.Plant is not abstract and does not override abstract method growthDirection() in garden.Plant
D
------
Exception in thread "main" java.lang.ExceptionInInitializerError at garden.Garden.main
Caused by: java.lang.RuntimeException: Uncompilable source code - garden.Plant is not abstract and does not override abstract method growthDirection() in garden.Plant
send
light_mode
delete
All Pages