Hi all,
I have create a program of multiple inheritance in java
My file name is 11.java
Here is my program : -
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 : - 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.
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 - 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: - Mno z=new Mno(57,67,76,81);
2 1134
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 - 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: - Mno z=new Mno(57,67,76,81);
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
by: Vla |
last post by:
why did the designers of c++ think it would be more useful than it turned
out to be?
|
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...
|
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...
|
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...
|
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
|
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...
|
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...
|
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
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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...
|
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...
| |