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


Please Help Members By Posting Answers For Below Questions

How do I find jre path in windows?

532


please mail me the interview question based on java/j2ee

1538


what is mean by hasing and maping in java platform and advantage?

1836


Which sorting algorithm is used by collections.sort() in java ?

555


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

1821






What are maps interfaces in the java collections? : java collections

576


What are the different types of collections views being provided by the map interface? : java collections

616


What are the types of java collections? : java collections

547


my interviewer asked me what technical specification you used how to answer that question

1935


What is the use of hashcode in java ?

582


What are the different types of ways where you can iterate over a list? : java collections

579


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 ?

1684


Which server-side script takes the input from JavaScript, can access the database if it needs to, and processes the data.

1602


What is the use of the list interface in the java collection? : java collections

606


What is the Spring2.5 MVC Navigation flow?

5378