class box{
double width;
double height;
double depth;
}
class bigbox extends box{
double weight;
}
class example49{
public static void main(String args[]){
bigbox b=new bigbox();
b.height=10;
b.width=20;
b.depth=30;
b.weight=50;
}
}
the above code compiles. if i add a constructor to the class box like belowclass box{
double width;
double height;
double depth;
box(box a){
width=a.width;
height=a.height;
depth=a.depth;
}
class bigbox extends box{
double weight;
}
class example49{
public static void main(String args[]){
bigbox b=new bigbox();
b.height=10;
b.width=20;
b.depth=30;
b.weight=50;
}
}
then i get the following error on compilingexample49.java:11: cannot find symbol
symbol : constructor box()
location: class box
class bigbox extends box{
^
1 errorif i again add a constructor to the class bigbox like belowclass box{
double width;
double height;
double depth;
box(box a){
width=a.width;
height=a.height;
depth=a.depth;
}
}
class bigbox extends box{
double weight;
bigbox(){
height=-1;
width=-1;
depth=-1;
weight=-2;
}
}
class example49{
public static void main(String args[]){
bigbox b=new bigbox();
b.height=10;
b.width=20;
b.depth=30;
b.weight=50;
//box a=new box(b);
}
}
i get the following error on compilingexample49.java:13: cannot find symbol
symbol : constructor box()
location: class box
bigbox(){
^
1 error
what is causing these errors?help please?
Edited by csepraveenkumar, 18 May 2011 - 06:28 AM.


Sign In
Create Account


Back to top










