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
What are the different types of collections views being provided by the map interface? : java collections
please mail me the interview question based on java/j2ee
What are the considerations to be made in case of loops in java ?
What are the types of java collections? : java collections
What are the types of the main implementing classes in the map interfaces? : java collections
Hi Friends , am newbie to ajax. For example just consider one account registration - A form contains 8 text fields with submit button. In this form second texbox contains "username " . On right side of text box there is a label box . On clilck action i need to determine user is available or not. Is it possible on clicking label or should i click submit button.
What is java collection? : java collections
What are the types of interface used in the java collections? : java collections
Which java collection class can be used to maintain the entries in the order in which they were last accessed?
What do you understand by synchronization? Why is it important?
Which interface does java.util.hashtable implement?
Which server-side script takes the input from JavaScript, can access the database if it needs to, and processes the data.
What is iterator in the java collections framework? : java collections
What is the use of hashcode in java ?
What are the interfaces in java collections? : java collections