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 main classes of the list interfaces? : java collections
What are the types of interface used in the java collections? : java collections
Explain the OOPS concept in Realtime Scenarion ? Take example as CAR. Please explain indetail ?
Hi Friends, i have searched in google but not clear. can you give bank example with synchronized keyword
What are the different types of collections views being provided by the map interface? : java collections
What is deque in the java collections framework? : java collections
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 are the different types of classes implemented in the set interfaces? : java collections
What are the interfaces in java collections? : java collections
What are the considerations to be made in case of loops in java ?
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.?.
What are the differences between the java collection and the java list? : 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 are the uses of the set interfaces in the java collections? : java collections
What is an algorithm in java collection framework? : java collections