Computing Magazine

What Will Be Output Of This Code

Posted on the 31 January 2014 by Abhishek Somani @somaniabhi
This is a very simple question which tests your concepts of overloading and overriding in java . Class 1 :

package com.test;
public class Super
{
public void method(Object obj)
{
System.out.println("Super one");
}
}
Class 2 :

package com.test;
public class SubClass extends Super
{
public void method(String s1)
{
System.out.println("Sub class");
}
}

package com.test;
public class OverrideTest
{
public static void main(String[] args)
{
Super obj = new SubClass();
obj.method("NJJJ");
}
}
So , What Will be Output Of this Code ??

Back to Featured Articles on Logo Paperblog

Magazines