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 / suma.k

in main method

Base b1=new Base ();
b1.m1();

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is deque in the java collections framework? : java collections

541


What is the difference between comparable and comparator in java.util pkg?

593


What is iterator in the java collections framework? : java collections

538


Which java collection class can be used to maintain the entries in the order in which they were last accessed?

561


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

1935






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

574


What are the differences between the java collection and the java list? : java collections

616


What is java collection? : java collections

581


What are the types of the main implementing classes in the map interfaces? : java collections

614


What is an algorithm in java collection framework? : java collections

582


Hi Friends, i have searched in google but not clear. can you give bank example with synchronized keyword

1615


How do I find jre path in windows?

529


What is the Spring2.5 MVC Navigation flow?

5374


Which interface does java.util.hashtable implement?

676


What are the classes in the java collection framework? : java collections

595