473,396 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Error occurred in program of multiple inheritance in java

Ajay Bhalala
119 64KB
Hi all,

I have create a program of multiple inheritance in java

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

Expand|Select|Wrap|Line Numbers
  1. class abc
  2. {
  3.     int a,b;
  4.     abc()
  5.     {
  6.         a=b=10;
  7.     }
  8.     abc(int x)
  9.     {
  10.         a=b=x;
  11.     }
  12. }
  13. class def extends abc
  14. {
  15.     int d,e,f;
  16.     def()
  17.     {
  18.         d=e=f=15;
  19.     }
  20.     def(int m,int n,int o)
  21.     {
  22.         super(m);
  23.         d=n;
  24.         e=f=0;
  25.     }
  26.     void dis()
  27.     {
  28.         System.out.print(a + " " + b + " " + d + " " + e + " " + f);
  29.     }
  30. }
  31. class mno extends def
  32. {
  33.     int m,n;
  34.     mno()
  35.     {
  36.         m=n=20;
  37.     }
  38.     mno(int q, int r, int s, int t)
  39.     {
  40.         super(q,r,s);
  41.         m=s;
  42.         n=t;
  43.     }
  44.     void show()
  45.     {
  46.         System.out.print(m + " " + n);
  47.     }
  48. }
  49. class exminh
  50. {
  51.     public static void main(String args[])
  52.     {
  53.         mno x=new mno();
  54.         mno y=new mno();
  55.         mno(57,67,76,81);
  56.         x.show();
  57.         x.dis();
  58.         y.show();
  59.         y.dis();
  60.     }
  61. }
  62.  
I have run this but the following error occurred :-

Error :
Expand|Select|Wrap|Line Numbers
  1. 11.java:55: cannot find symbol
  2. symbol : method mno(int,int,int,int)
  3. location: class exminh
  4.                 mno(57,67,76,81);
  5.                 ^
  6. 1 error
Please give me any suggestion to solve this error.
Oct 7 '15 #1

✓ answered by chaarmann

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
Expand|Select|Wrap|Line Numbers
  1. 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:
Expand|Select|Wrap|Line Numbers
  1. Mno z=new Mno(57,67,76,81);

2 1134
chaarmann
785 Expert 512MB
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
Expand|Select|Wrap|Line Numbers
  1. 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:
Expand|Select|Wrap|Line Numbers
  1. Mno z=new Mno(57,67,76,81);
Oct 8 '15 #2
Ajay Bhalala
119 64KB
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.
Oct 8 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Hung Jung Lu | last post by:
Hi, I think Microsoft did look into Python when they designed C#. (E.g. they got rid of checked exceptions of Java.) However, they followed Java in avoiding multiple inheritance (MI), which is a...
30
by: Vla | last post by:
why did the designers of c++ think it would be more useful than it turned out to be?
3
by: Tony Johansson | last post by:
Hello experts! I have a small program that is using multiple inheritance. There are 4 classes involved I get 4 compile error that I can't figure out why. It's this row which is located in the...
5
by: Tony Johansson | last post by:
Hello Experts! I just play around just to try to understand this about multiple inheritance. You have all the class definition below and at the bottom you have the main program. So here I...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
29
by: MAHESH MANDHARE | last post by:
Hi , Can Anyone explain me exactly why multiple inheritance not used in java and c# thanks, Mahesh -- Have A Good Day, Mahesh, Maheshmandhare@yahoo.co.in
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
18
by: GD | last post by:
Please remove ability to multiple inheritance in Python 3000. Multiple inheritance is bad for design, rarely used and contains many problems for usual users. Every program can be designed only...
1
by: Goldy T Joseph | last post by:
#include<iostream.h> #include<conio.h> class doctor { char name,dp,speci; public: void read(); void print(); }; class patient
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.