Invoke overriden method in grandparent class(wth trivial example)

Hi,can any one help? Please read the following trivial example
class BaseA{
public void showName(){
System.out.println("This is BaseA");
class BaseB extends BaseA{
public void showName(){
System.out.println("This is BaseB");
class Child1 extends BaseB{
public void showName(){
System.out.println("This is Child1");
public void showParentName(){
super.showName();
public void showGrandName(){
//How can I invoke showName() method in grandparent class BaseA
public class Test2{
public static void main(String arg[]){
Child1 obj1= new Child1();
obj1.showName();
obj1.showParentName();
I remember I read a book that mentions how to get around this trouble,but it is really long time ago,can anyone help? a million of thanks

There might be better way to this but might be below is also work
class BaseA{
public void showName(){
System.out.println("This is BaseA");
class BaseB extends BaseA{
public void showName(){
System.out.println("This is BaseB");
public void showParentName(){
super.showName();
class Child1 extends BaseB{
public void showName(){
System.out.println("This is Child1");
public void showParentName(){
super.showName();
public void showGrandName(){
//How can I invoke showName() method in grandparent class BaseA
super.showParentName();
public class Test2{
public static void main(String arg[]){
Child1 obj1= new Child1();
obj1.showName();
obj1.showParentName();
obj1.showGrandName();

Similar Messages

  • Invoke a method in one class from a different class

    I am working on a much larger project, but to keep this simple, I wrote out a little test that would convey the over all theory of the program.
    What I am doing is starting out with a 2 JFrames and a Class. When the program is launched, the first JFrame opens. In this JFrame is a label and a button. When the button is clicked, the second JFrame opens. This JFrame has a textField and a button. The user puts the text in the textField and presses the button. When the button is pushed, I want the text that was just put in the textField, to be displayed in the first JFrame's label. I am trying to invoke a method in the first JFrame from the second, but nothing happens. I have also tried making the Class extend from JFrame1 and invoke it from there, but no luck. So, how do I invoke a method in a class from a different class?
    JFrame1 (I omitted the layout part. I made this in Netbeans so its pretty long)
    public class NewJFrame1 extends javax.swing.JFrame {
         private NewClass1 nC = new NewClass1();
         /** Creates new form NewJFrame1 */
         public NewJFrame1() {
              initComponents();
              jLabel1.setText("Chuck");
         public void setLabels()
              jLabel1.setText(nC.getName());
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                                  
         NewJFrame2 j2 = new NewJFrame2();
         j2.setVisible(true);The class
    public class NewClass1 {
         public static String name;
         public NewClass1()
         public NewClass1(String n)
              name = n;
         public String getName()
              return name;
         public void setName(String n)
              name = n;
    }The second jFrame
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                                  
         NewClass1 nC = new NewClass1();
         NewJFrame1 nF = new NewJFrame1();     
         nC.setName(jTextField1.getText());
         nF.setLabels();
         System.out.println(nC.getName());At this point I am begging for help. I have been trying for days to figure this out, and I just feel like I am not getting anywhere.
    Thanks

    So, how do I invoke a method in a class from a different class?Demo:
    public class Main {
        public static void main(String [] args) {
         Test1 t1 = new Test1();
         Test2 t2 = new Test2();
         int i = t1.method1();
         String s = t2.method2(i);
         System.out.println(s);
    class Test1 {
        public int method1() {
         return 10;
    class Test2 {
        public String method2(int i) {
         if (i == 10)
             return "ten";
         else
             return "nothing";
    }Output is "ten".
    Edited by: newark on May 28, 2008 10:55 AM

  • Invoke a Method of a Class

    Hello !
    Below I am giving my Problem.....
    I hav a List Class Named as : DepartmentList and a method called getInstance()
    Now if that is a class then i must call it as :
    DepartmentList deptInst=new DepartmentList()
    then method call as : deptInst.getInstance()
    But unfortuntly,
    now I've a String strClass="DepartmentList";
    and String strMethod="getInstance";
    I've to invoke that method.. How ???
    Plz give the solution..
    Hint: Check forName(..) to get the appropiate Class then it's method... But unable to invoke that method..
    Thanks !
    BS

    You can get a class using the Class.forName method like this:
    Class clazz = Class.forName ("DepartmentList");Note that you have to add any package names to this name as well or else it will not find the class.
    Then there's a getMethod method available that takes the name of the method and any number of parameter classes. In your case this would be:
    Method meth = clazz.getMethod ("getInstance");you can then call invoke on this method object. See the javadoc for what parameters you exactly need, if any :)
    good luck !

  • Invoking a method on an URL request?

    i want to invoke a method of a class on an URL request,such that the method can navigate the control to number of other pages .

    Implement a Filter.

  • How to call parent`s overriden method?

    Hello all!
    I do not know how to call overriden method outside
    the class. Example:
    class A {
         public String method() {
              return new String("A");
    class B extends A {
         public String method() {
              return new String("B");
    public class test {
         public static void main(String[] s) {
              A a = new A();
              B b = new B();
              // this is simple
              System.out.println(a.method()); // result: A
              System.out.println(b.method()); // result: B
              // now I need to call method from object A
              System.out.println(((A) b).method()); // res.: B
    At the last line the result was "B". It just implies from
    polymorphism but what I need is to call A.method()
    on object of type B.
    From real world. Have a class with some toString() method.
    I inherited this class and made a new toString() methods that
    adds some more information. Now I have a collection of various
    sub-classes and I need to print their information but in
    one style. I need to call the parent`s toString() method not
    the children ones...
    How to do it? How to create A.method() on object of type B?
    In C# there is a way not to use virtual/ovveride but to
    use virtual/new keywords...
    Please help me. Thank you very much.

    Just thought of something else you can try (if it's that important):public class A {
        public String toString () {
            return "A";
    public class B extends A {
        public String toString () {
            return "B (A: " + super.toString () + ")";
    }Kind regards,
      Levi

  • Can we invoke a method using BCEL(byte code engineering library)

    Hi i am new in Java bcel,So can anyone guide me in this problem.
    I am searching for some techniques in BCEL to invoke a method of some class just like we use to invoke methods using Java Reflection.I have also tried a Java Assembler named "Jasmin" that used to interact with Operand Stack,Local variable array & Constant Pool etc so i guess this is the same containers with which our BCEL also interact with so then i am wondering why not then there exists a way through which we can invoke a method using BCEL IF this will happen in any case then kindly point it out some direction of help.
    thanks in advance

    856989 wrote:
    I think i have clearly mentioned that "Tell me any way in doing this invocation in BCEL not in Reflection."
    Why i not want to use reflection because it have "invocation overhead"Wrong.
    If I dynamically load a class and reference it via a interface there is absolutely no difference in that and if I referenced the class statically and used it via an interface. The load and use process is exactly the same.
    And the first uses "reflection".
    If you use a proxy interface via something like java.lang.reflect.Method
    then of course there is some overhead because there is in fact more classes involved. Just as if you had any other layer in any other code.
    And even so unless you have actually profiled the application and found an actual bottleneck (and not just a measured impact) then even looking at it is a waste of time.
    If it was me I would be far more concerned that inserting byte codes was correct for all cases.

  • Invoking super methods

    I am trying to invoke a method on a class and all of it's super classes, however I'm getting the (rather predicable?) outcome where I always end up invoking the child classes method:
    public class A {
         public String getName() {
              return "A";
    public class B extends A {
         public String getName() {
              return "B";
    import java.lang.reflect.Method;
    public class Test {
         public static void main(String[] args) {
              try {
                   B b = new B();
                   Class c = b.getClass();
                   while (c != Object.class) {
                        Method m = c.getDeclaredMethod("getName", null);
                        System.out.println(m.invoke(b, null));
                        c = c.getSuperclass();
              } catch (Exception e) {
                   e.printStackTrace();
    }The result is always B B getting printed. I would definitly expect that if I was using getMethod, but I was hoping getDeclaredMethod would behave differently and print B A.
    Does anyone know how I would go about getting that result?

    The more I thought about it, the more I realized I was trying to have a parent class deduce information about it's unborn children, bad OO design. Anything that was getting this complicated must not have been done right....
    An example of what I was trying to do:
    public class A {
         public String getName() {
              return "A";
         public String getNames() {
              return "Class:A";
    public class B extends A {
         public String getName() {
              return "B";
         public String getNames() {
              return super.getNames() + "->Class:B";
    }Except I wanted getNames() to be final in A (so I wouldn't need to leave it to chance that children would implement getNames() properly) and when it was involked in the context of B still be able to draw line up the inheritence tree. Thanks for looking at this, but I think I'm going to re-think my design.

  • How to get a LabVIEW class object to expose an invoke-node method?

    Hi,
          I like the property/invoke-node "paradigm" used for interacting with "objects".  Can LabVIEW-class objects expose their properties and methods this way?  Can one or more LabVIEW-class objects be compiled into a library or "assembly" (or other distrubution format) that allows the property/invoke-node usage?
    I've looked at (but not completely understood) "Creating LabVIEW Classes".  Have also searched for related posts.
    The pic below shows an invoke node wired to a class with a Public VI "VAT.Status.Hello.vi".  I'd like to see VAT.Status.Hello show-up as a Method.  (I just tried "Select Method", and selected "VAT.Status.Hello.vi" but dialog's "OK" button stays greyed-out.)
    Cheers.
    Message Edited by tbd on 03-29-2007 03:15 PM
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
    Attachments:
    VATStat.JPG ‏54 KB

    Hi Aristos,
          Thanks for the reply!  It was a bit dissappointing, though.
    It appears the LabVIEW-class object will be moving away from (what seems to me) a convenient object-interface presented by the invoke-node/method paradigm - which allows us to interface with a large set of "objects" (.NET, ActiveX, LabVIEW GUI, VISA Resource, ?) in a similar manner and independent of the object's origin.  Being able to read the methods and parameters that appear in these nodes is also helpful for understanding diagram logic!
    I do like the option of dropping a friendly "VI looking" icon on the diagram, but perhaps an optional - even default - VI-icon representation for a class-object invoke-node is feasible - so the LabVIEW class-object could be the more generic object first, but with a traditional-G representation(?)
    Given the answer "We would like, someday, to support the property node"
    and "in the next version of LV, wiring the LV class to the property/invoke nodes will break the wire so we'll avoid confusion in the future",
    ... I guess you'll break the wire in the next version, but (perhaps) allow it again - if support of the property node is ever implemented?
    Regards.
    P.S. For the record, huge THANKS to whoever it was that straightened-out enumerated-types (somewhere) between LV4.1 and LV6.1.  Every time I add or remove an enumeration in a typedef, I silently give thanks to the bright and thoughtful soul(s) who made this valuable tool work so well!
    Hello. This is your friendly neighborhood R&D guy for LabVIEW classes.
    Regarding your request about property and invoke nodes as relates to LV classes....
    Short story: We would like, someday, to support the property node. We have no intention of ever supporting the invoke node.
    Long story: As we were creating LV classes, we had to evaluate the right programming interface for these things. We wanted LV classes to behave as new data types in LV. A developer should be able to create a LV class, then give it to someone who doesn't even know OO programming, and that second programmer could use the new data type without learning a lot of new concepts. From this principle, we held fast to the idea that the programming interface should be subVI calls whereever possible. The invoke node is really nothing more than a VI minus the icon. If you want, you can popup on any subvi node and uncheck the option "View as Icon". This will make the node display in a way that has the terminals listed as text, like the invoke node. So, at the end of the day, the invoke node is simply a subroutine call in LV that is language dependent, as opposed to the language independent iconography of LV generally.
    The property node is a slightly different story -- the functionality of a property node is actually different than an invoke node as its terminals are various subsets of the properties available, not a fixed list of parameters like the invoke node. The property node provides a nice interface for setting multiple properties in a block and only having to check a single error return. Very friendly. Our intent is to allow you to create a VI that has 5 terminals: object in, object out, error in, error out, and either a single input or a single output of your chosen type. VIs with this conpane could be marked as "properties" of the class and would show up when you wire the class wire to the property node. We would call the subVIs behind the scenes as needed to get/set the properties.
    This is on the longer term roadmap because it is "syntactic sugar" -- it sweetens the programming style, but it is not necessary to program effectively. You can get the same effect by writing those same VIs and stringing them along on a block diagram "railroad track" style. We'll probably get around to it in three or four versions of LV -- there are some major user requests that impact functionality that have to get done first.
    PS -- in the next version of LV, wiring the LV class to the property/invoke nodes will break the wire so we'll avoid confusion in the future of people thinking there's a way to use these nodes.
    Message Edited by Aristos Queue on 04-02-2007 09:56 AM
    Message Edited by tbd on 04-03-2007 12:39 PM
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)

  • Invoking a method in WSDL file from client class

    Hi,
    I have got a WSDL file and I have to invoke certian methods from a client class from the WSDL file. What exactly should I do to invoke them from a Java standalone program /servlet/JSP. There is a sayHello() method in the WSDL. Please tell me how to invoke that method from client side. Aslo please let me know the jar files that are needed.
    Below is the WSDL file
    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions targetNamespace="http://tutorial.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://tutorial.com" xmlns:intf="http://tutorial.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <!--WSDL created by Apache Axis version: 1.2.1Built on Jun 14, 2005 (09:15:57 EDT)-->
    <wsdl:message name="sayHelloResponse">
    </wsdl:message>
    <wsdl:message name="sayHelloResponse1">
    <wsdl:part name="sayHelloReturn" type="xsd:string"/>
    </wsdl:message>
    <wsdl:message name="addRequest">
    <wsdl:part name="a" type="xsd:int"/>
    <wsdl:part name="b" type="xsd:int"/>
    </wsdl:message>
    <wsdl:message name="sayHelloRequest">
    </wsdl:message>
    <wsdl:message name="addResponse">
    <wsdl:part name="addReturn" type="xsd:int"/>
    </wsdl:message>
    <wsdl:message name="sayHelloRequest1">
    <wsdl:part name="name" type="xsd:string"/>
    </wsdl:message>
    <wsdl:portType name="Hello">
    <wsdl:operation name="sayHello">
    <wsdl:input message="impl:sayHelloRequest" name="sayHelloRequest"/>
    <wsdl:output message="impl:sayHelloResponse" name="sayHelloResponse"/>
    </wsdl:operation>
    <wsdl:operation name="sayHello" parameterOrder="name">
    <wsdl:input message="impl:sayHelloRequest1" name="sayHelloRequest1"/>
    <wsdl:output message="impl:sayHelloResponse1" name="sayHelloResponse1"/>
    </wsdl:operation>
    <wsdl:operation name="add" parameterOrder="a b">
    <wsdl:input message="impl:addRequest" name="addRequest"/>
    <wsdl:output message="impl:addResponse" name="addResponse"/>
    </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="HelloSoapBinding" type="impl:Hello">
    <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="sayHello">
    <wsdlsoap:operation soapAction=""/>
    <wsdl:input name="sayHelloRequest">
    <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://tutorial.com" use="encoded"/>
    </wsdl:input>
    <wsdl:output name="sayHelloResponse">
    <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://tutorial.com" use="encoded"/>
    </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="sayHello">
    <wsdlsoap:operation soapAction=""/>
    <wsdl:input name="sayHelloRequest1">
    <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://tutorial.com" use="encoded"/>
    </wsdl:input>
    <wsdl:output name="sayHelloResponse1">
    <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://tutorial.com" use="encoded"/>
    </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="add">
    <wsdlsoap:operation soapAction=""/>
    <wsdl:input name="addRequest">
    <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://tutorial.com" use="encoded"/>
    </wsdl:input>
    <wsdl:output name="addResponse">
    <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://tutorial.com" use="encoded"/>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="HelloService">
    <wsdl:port binding="impl:HelloSoapBinding" name="Hello">
    <wsdlsoap:address location="http://localhost/WebService1/services/Hello"/>
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>
    Thanks in advance
    Prashanth

    Hi.
    Please put this line in the google search engine "Invoking java web service" u will get lots of the links.
    Sanjay Kumar Gupta
    [email protected]

  • How to find the class name, the location from where it invoked a method

    Hi,
    I have a class A. The caller calls A.someMethod(), whenever this method is invoked, I want to find out the caller info, which class invoked this method, from where this class was loaded (may be the jar file name). Any help will be appreciated.
    Thanks.

    However since version 1.4 there is an easier way to extract that information from the Throwable:
    java.lang.Throwable
    public StackTraceElement[] getStackTrace()
    Provides programmatic access to the stack trace information printed by printStackTrace(). Returns an array of stack trace elements, each representing one stack frame.

  • Invoking the main() method of a class within another

    Greetings -
    Can someone tell me what happens when you invoke the main() method of a class from within another class?
    I have a third-party class, designed to be invoked from a command line, that I want to invoke from within a separate class. What appears to be happening is that following the successful execution of the third-party class, the invoking class is terminated as well. That's not the intended behavior I had envisioned. ^_^
    Is there a better way than invoking the main() method? I still need the invoking class to continue executing.
    Thanks!

    Navigate yourself around pitfalls related to the Runtime.exec() method

  • Dynamically invoke methods of abstract class?

    Hi,
    I am using reflection to write a class (ClassA) to dynamically invoke methods of classes. I have an abstract class (ClassB) that has some of the methods already implemented, and some of the methods that are declared abstract. Is there any way that I can:
    (a) invoke the methods that are already implemented in ClassB;
    (b) I have another class (ClassC) that extends ClassB, some of the methods are declared in both classes. Can I dynamically invoke these methods from ClassB?
    Thanks in advance,
    Matt.

    Ok, the program is quite long, as it does other things as well, so I'll just put in the relevant bits.
    What I have is a JTree that displays classes selected by the user from a JFileChooser, and their methods.
    // I declare a variable called executeMethod
    private static Method executeMethod;
    // objectClass is a class that has been chosen by the user.  I create a new instance of this class to execute the methods.
    Object createdObject = objectClass.newInstance();
    // methodName is the method selected by the user.  objectClassMethods is an array containing all the methods in the chosen class.
    executeMethod = objectClassMethods[j].getDeclaringClass().getMethod(methodName, null);
    Object executeObject = executeMethod.invoke(createdObject, new Object[]{});Ok, here are the test classes:
    public abstract class ClassB{
         private int age;
         private String name;
         public ClassB(){ age = 1; name="Me";}
         public int getAge(){ return age; }
         public String getName(){ return name; }
         public void PrintAge(){System.out.println(age);}
         public void PrintName(){System.out.println(name);}
         public abstract void PrintGreeting();
    public class ClassC extends ClassB{
         public ClassC(){super();}
         public void PrintAge(){
              System.out.println("I am " + getAge() + " years old.");
         public void PrintGreeting(){
           System.out.println("Hello");
    }Now, I can print out the PrintAge method from ClassC (i.e. have it output "Hello" to the command line, how can I, say, get it to output the result of PrintName from ClassB, this method does not appear in ClassC. As you can see at the top, I can create a new instance of a normal method (in this case, ClassC), and have it output to the command line, but I know that I can't create a new instance of an abstract class. And since PrintName is implemented in abstract class ClassB, how do I get it to output to the command line?
    Thanks,
    Matt.

  • Can i invoke a method of a different class?

    I want to tell my method that if a certain event occurs, to invoke a method thats located in a different class but in the same package. But neither inherit each other.
    I also want the original method to pass parameters to the remote method so it can perform actions on them.
    Is this possible somehow, or am I barking up the wrong tree?
    I've included an example to illustate.
    edu.example;
    public class one extends bank{
    protected void count (){
    If i>100{
    spend(5); // method thats in the two class
    else break;
    edu.example;
    public class two extends bank{
    protected void spend (int x){
    i = i - x;

    either the method you want to invoke will have to be static, or you will need an instance of the class that contains the method you want to invoke.
    If your not in school, its probably best you buy a Java book. It will speed things along considerably.
    I have always bought books by Ivor Horton. "Beginning Java" is a good one. Wrox publisher I think. Once you pass that book you will not need any other books unless you go deep into a particular subject such as encryption.

  • Invoking a method from a java class to a jsp file

    Maybe i'm going through a very basic error, but as i've looked for in some forums and nothing found decided to post. So let's go to the problem.
    Well, i have a form in a jsp file, it's basicaly html, but as i need some select boxes populated with data from the database i decided to create some methods in java classes. This is the point.
    My method receive some attributes, like the table and colums names, the name of the select box and the HttpServletResponse object.
    So after making all the database process. The method is supposed to write the result through the out.println(); object
    It goes everything all right except that the method seems to be called first than the html code coz' my select boxes comes above the head in the begin of the page and was supposed to come in the middle.
    part of the code:
    package pacote;
    import java.packages.*
    public class Class{
    public void metodo(HttpServletResponse response, String tableName, String column name, String selectName){
    PrintWriter out = response.getWriter();
    openConnection();
    //After making the query stuff
    //caso n�o haja nada na consulta
         if(rst == null)
         out.println("N�o h� registros.");
         else{
         out.println( "<select name='" +SelectName + "' id='" +SelectName + "' class=\"input_ob\" >");
         out.println( "<option value=''>Escolha: "+objeto+"</option>");
         //fill the select body with options; A while that sweap the resultSet and use the out object to write the results          
         getSelectBody(out,rst, selectValue);
    }This method is called this way:
    <tr valign="baseline">
        <td nowrap align="right">Grupo</td>
        <jsp:useBean id="m" scope="page" class="pacote.Class" />
            <td>
              <%
              try{
                   m.metodo(response, "tabela","grupo","id_grupo);
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
                        %></td>I'd like to know what i'm missing here. why the answer doesn't go in the place It's supposed to go.
    any answer will be greatly apreciated

    The issue is caused because you are using the response to get the writer directly.
    The JSP has gotten the same writer, but has wrapped it in a JSPWriter class. That class has got a buffer.
    So it writes the beginning html to the JSPWriter buffer.
    You write your stuff to the response writer - gets sent to the output.
    It writes more stuff to the JSPWriter buffer, then flushes that buffer - at which point all the text written into the JSP writer now gets added to the response.
    You see how your code is coming out first?
    Solution - instead of getting the writer from the response, pass the writer into your method (maybe instead of response if you don't use response for anything else)
    public void metodo(Writer jspWriter, String tableName, String column name, String selectName){
      PrintWriter out = new PrintWriter(jspWriter);
      ...That means that you will be writing to the same writer, and the text should come out in sequence.
    Cheers,
    evnafets

  • Access overriden method of an abstract class

    class Abstract
    abstract void abstractMethod(); //Abstract Method
    void get()
    System.out.print("Hello");
    class Subclass extends Abstract
    void abstractMethod()
    System.out.print("Abstract Method implementation");
    void get()
    System.out.print("Hiiii");
    In the above code, i have an abstract class called "Abstract", which has an abstract method named "abstractMethod()" and another method called "get()".
    Now, this class is extended by "Subclass", it provides implementation for "abstractMethod()", and also overrides the "get()" method.
    Now my problem is that i want to access the "get()" method of "Abstract" class. Since it is an abstract class, i cant create an object of it directly, and if i create an object like this:
    Abstract obj = new Subclass();
    then, obj.get() will call the get() method of Subclass, but how do i call the get() method of Abstract class.
    Thanks in advance

    hey thanks a lot,, i have another doubt regarding Abstract classes.
    i was just trying something, in the process, i noticed that i created an abstract class which does not have any abstract method, it gave no compilation errors. was wondering how come this is possible, and what purpose does it solve?

Maybe you are looking for