How to call the m1() method of Base class in below snippet ?
class Base
{
public void m1()
{
System.out.println("Base m1 ");
}
public void m2()
{
System.out.println("Base m1 ");
}
}
======================
class Derived extends Base
{
public void m1()
{
System.out.println("Derived m1");
}
public void m3()
{
System.out.println("Derived m3");
}
public static void main(String[] args)
{
Base ob=new Derived();
ob.m1();
//System.out.println("Hello
World!"+ob.m1());
}
}
Answer Posted / mitu
class Derived extends Base
{
public void m1()
{
System.out.println("Derived m1");
}
public void m3()
{
System.out.println("Derived m3");
}
public void m26()
{
super.m1();
}
public static void main(String[] args)
{
Derived ob=new Derived();
ob.m1();
ob.m26();
}
}
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How do I find jre path in windows?
please mail me the interview question based on java/j2ee
what is mean by hasing and maping in java platform and advantage?
Which sorting algorithm is used by collections.sort() in java ?
who will give req's to u?. how they send req's to u? . what design documents contains?. when bugs raised on other developer code how to report to them?.(throgh mail or ........). how to retrive 100 recods from dao layer to presentation layer.using which collection?. what is sequence diagram.?.
What are maps interfaces in the java collections? : java collections
What are the different types of collections views being provided by the map interface? : java collections
What are the types of java collections? : java collections
my interviewer asked me what technical specification you used how to answer that question
What is the use of hashcode in java ?
What are the different types of ways where you can iterate over a list? : java collections
In hyderabad, which s/w training center is best for java, other than corejava what r the new tools to learn in java,which tool is best & have current requirement,pls give me information about java to learn ?
Which server-side script takes the input from JavaScript, can access the database if it needs to, and processes the data.
What is the use of the list interface in the java collection? : java collections
What is the Spring2.5 MVC Navigation flow?