READ Free Dumps For Oracle- 1z0-803
Question ID 21933 | Given a java source file:
class x {
x () {}
private void one () {}
}
public class Y extends x {
Y () {}
private void two () {one();}
public static void main (string [] args) {
new Y().two ();
}}
What changes will make this code compile?
|
Option A | adding the public modifier to the declaration of class x
|
Option B | adding the protected modifier to the x() constructor
|
Option C | changing the private modifier on the declaration of the one() method to protected
|
Option D | removing the Y () constructor
|
Option E | removing the private modifier from the two () method
|
Correct Answer | C |
Explanation Explanation: Using the private protected, instead of the private modifier, for the declaration of the one() method, would enable the two() method to access the one() method.
Question ID 21934 | Given:
#1
package handy.dandy;
public class KeyStroke {
public void typeExclamation() {
System.out.println("!")
}}
#2
package handy; /* Line 1 */
public class Greet { /* Line 2 */
public static void main(String[] args) { /* Line 3 */
String greeting = "Hello"; /* Line 4 */
System.out.print(greeting); /* Line 5 */
Keystroke stroke = new Keystroke; /* Line 6 */
stroke.typeExclamation(); /* Line 7 */
} /* Line 8 */
} /* Line 9 */
What three modifications, made independently, made to class greet, enable the code to compile and run?
|
Option A | Line 6 replaced with handy.dandy.keystroke stroke = new KeyStroke ( );
|
Option B | Line 6 replaced with handy.*.KeyStroke = new KeyStroke ( );
|
Option C | Line 6 replaced with handy.dandy.KeyStroke Stroke = new handy.dandy.KeyStroke();
|
Option D | import handy.*; added before line 1
|
Option E | import handy.dandy.*; added after line 1
|
Option F | import handy.dandy,KeyStroke; added after line 1
|
Correct Answer | C,D,F |
Explanation Explanation: Three separate solutions: C: the full class path to the method must be stated (when we have not imported the package) D: We can import the hold dandy class F: we can import the specific method