Error occurred in program of multiple inheritance in java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ajay Bhalala
    New Member
    • Nov 2014
    • 119

    Error occurred in program of multiple inheritance in java

    Hi all,

    I have create a program of multiple inheritance in java

    My file name is 11.java
    Here is my program :

    Code:
    class abc
    {
    	int a,b;
    	abc()
    	{
    		a=b=10;
    	}
    	abc(int x)
    	{
    		a=b=x;
    	}
    }
    class def extends abc
    {
    	int d,e,f;
    	def()
    	{
    		d=e=f=15;
    	}
    	def(int m,int n,int o)
    	{
    		super(m);
    		d=n;
    		e=f=0;
    	}
    	void dis()
    	{
    		System.out.print(a + " " + b + " " + d + " " + e + " " + f);
    	}
    }
    class mno extends def
    {
    	int m,n;
    	mno()
    	{
    		m=n=20;
    	}
    	mno(int q, int r, int s, int t)
    	{
    		super(q,r,s);
    		m=s;
    		n=t;
    	}
    	void show()
    	{
    		System.out.print(m + " " + n);
    	}
    }
    class exminh
    {
    	public static void main(String args[])
    	{
    		mno x=new mno();
    		mno y=new mno();
    		mno(57,67,76,81);
    		x.show();
    		x.dis();
    		y.show();
    		y.dis();
    	}
    }
    I have run this but the following error occurred :-

    Error :
    Code:
    11.java:55: cannot find symbol
    symbol : method mno(int,int,int,int)
    location: class exminh
                    mno(57,67,76,81);
                    ^
    1 error
    Please give me any suggestion to solve this error.
  • chaarmann
    Recognized Expert Contributor
    • Nov 2007
    • 785

    #2
    In line 55 , you are trying to call method "mno" in class "exminh", but it does not exist. Instead, you have defined it as constructor of class "mno". Sso to call it, you have to change this line to
    Code:
    mno z=new mno(57,67,76,81);
    By the way, please get used to java coding standards! Beginners think they are not important, but experts can strongly confirm you that they are. Classes are written with a capital letter at the beginning, but methods not! That is exactly the point why this error happened to you: you thought that "mno" is a method because of lower-case, but in reality it is a class constructor that you have wrongly written with lowercase. So after correction, the correct line 55 would be:
    Code:
    Mno z=new Mno(57,67,76,81);

    Comment

    • Ajay Bhalala
      New Member
      • Nov 2014
      • 119

      #3
      Thank you so much for solving my error and also for your great and very useful suggestion.

      Your suggestion is really very useful

      Thank You soooooooo much.

      Comment

      Working...