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(int 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('a');
    }
}
Output:
int: 97

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...