InterviewSolution
Saved Bookmarks
| 1. |
Predict the output of following program. Note that foo() is public in base and private in derived.class Base {public void foo() { System.out.println("Base"); }}class Derived extends Base {private void foo() { System.out.println("Derived"); }}public class Main {public static void main(String args[]) {Base b = new Derived();b.foo();}}(A) Base(B) Derived(C) Compiler Error(D) Runtime Error |
| Answer» | |