Sunday, July 15, 2018

What will be the output of overriding concept?

Problem statement: what will be the output of the below code?
class C {
    public void run(char a) {
        System.out.println("int: " + a);
    }

    public void run(long a) {

        System.out.println("long");
    }
}
public class DemoSample1 {
    public static void main(String args[]) {
        C c = new C();
        c.run('9');
    }
}
Output:
int: 9

No comments:

Post a Comment

Blueprint for self-improvement

To learn faster: Make the process fun To understand yourself : Write To understand the world better : Read To build deeper connection : Lis...