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
What are the types of java collections? : java collections
What are the considerations to be made in case of loops in java ?
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
What are the different types of collections views being provided by the map interface? : java collections
can u draw class/object diagram for ATM
What are the different types of ways where you can iterate over a list? : java collections
How do I find jre path in windows?
What is iterator in the java collections framework? : java collections
What are the types of interface used in the java collections? : java collections
Should we create system software ( e.g operating system ) in java ?
Explain the OOPS concept in Realtime Scenarion ? Take example as CAR. Please explain indetail ?
Hi frnds how to lock an user when he enter wrong credentials more than 3 time using java or j2ee tech take username and password in a bean no need to connect DB and validate give me some sample application code or links its urgent for me thanks in advance
What is the use of hashcode in java ?
What is the use of the list interface in the java collection? : java collections
HOW MUCH PERCENTAGE WE DEDUCT FOR OUR SUPPLIERS OR OTHER PROFESSIONALS