Question
class area {
int width;
int length;
int volume;
area() {
width=5;
length=6;
}
void volume() {
volume = width*length*height;
}
}
class cons_method {
public static void main(String args[])
{
area obj = new area();
obj.volume();
System.out.println(obj.volume);
}
}
What is the output of this program?
class area {
int width;
int length;
int volume;
area() {
width=5;
length=6;
}
void volume() {
volume = width*length*height;
}
}
class cons_method {
public static void main(String args[])
{
area obj = new area();
obj.volume();
System.out.println(obj.volume);
}
}
Answer: Option D
Was this answer helpful ?
Variable height is not defined.
output:
$ javac cons_method.java
$ java cons_method
error: cannot find symbol height
Was this answer helpful ?
Submit Solution