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

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

1595


What do you understand by synchronization? Why is it important?

568


Which interface does java.util.hashtable implement?

667


What are the interfaces in java collections? : java collections

611


What are the main classes of the list interfaces? : java collections

574






HOW MUCH PERCENTAGE WE DEDUCT FOR OUR SUPPLIERS OR OTHER PROFESSIONALS

1578


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

558


can u draw class/object diagram for ATM

5527


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 ?

1675


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

533


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

546


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

572


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

1933


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

613


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

568