473,322 Members | 1,911 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,322 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 1130
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.