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 / surendra

in main() create an object to derived class and call m1() by using this obj since all super class members are available to
subclass object.
Derived d=new Derived();
d.m1();

Is This Answer Correct ?    1 Yes 2 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

538


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

589


What are the different types of features of the java collections framework? : java collections

568


Explain the OOPS concept in Realtime Scenarion ? Take example as CAR. Please explain indetail ?

2561


HOW MUCH PERCENTAGE WE DEDUCT FOR OUR SUPPLIERS OR OTHER PROFESSIONALS

1578






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

572


Hi we have an urgent requirement for Java/J2ee technical lead position & also looking for "Java Guidewire claimcentre" experienced professional for Bangalore location if interested can reach srisanh@gmail.com

2534


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

613


What is the enumerator of the java collection framework? : java collections

561


What are the interfaces in java collections? : java collections

611


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

611


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

1813


What is the use of hashcode in java ?

573


What are the considerations to be made in case of loops in java ?

564


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

569