Java Reference
In-Depth Information
6.
7. class Child extends Parent {
8. public void sayHi() {
9. System.out.print(“Hello”);
10. }
11. }
what is output of the result of the following statements?
15. Parent p = new Child();
16. p.sayHi();
A.
Hi
B.
Hello
C.
Compiler error on line 8
D.
Compiler error on line 15
E.
Line 16 causes an exception to be thrown.
7.
What is the result of the following code?
1. public class Beverage {
2. private int ounces = 12;
3. boolean carbonated = false;
4.
5. public static void main(String [] args) {
6. System.out.println(new SodaPop());
7. }
8. }
9.
10. class SodaPop extends Beverage {
11. public String toString() {
12. return ounces + “ “ + carbonated;
13. }
14. }
A.
12 false
B.
Compiler error on line 6
C.
Compiler error on line 10
D.
Compiler error on line 11
E.
Compiler error on line 12
8.
What is the result of the following code?
1. public class Fruit {
2. private String color = “Green”;
Search WWH ::
Custom Search